MerchantUserAndBalanceModel.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class MerchantUserAndBalanceModel extends Model
  5. {
  6. /**
  7. * 批量获取用户余额
  8. * @param $userIds
  9. * @return array
  10. * @throws \think\db\exception\DataNotFoundException
  11. * @throws \think\db\exception\DbException
  12. * @throws \think\db\exception\ModelNotFoundException
  13. */
  14. public static function getMerchantUserBalance($userIds, $field = ['user_id', 'balance']) {
  15. $query = self::table('tp_merchants_user_balance')->whereIn('user_id', $userIds);
  16. if(!empty($field)) {
  17. $query = $query->field($field);
  18. }
  19. return $query->select()->toArray();
  20. }
  21. /**
  22. * 批量获取用户信息
  23. * @param $userIds
  24. * @return array
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\DbException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. */
  29. public static function getMerchantUser($userIds, $field = ['user_id', 'nickname'])
  30. {
  31. $query = self::table('tp_merchants_user')->whereIn('user_id', $userIds);
  32. if(!empty($field)){
  33. $query = $query->field($field);
  34. }
  35. return $query->select()->toArray();
  36. }
  37. }