MerchantUserAndBalanceModel.php 1.3 KB

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