CommonMerchantUserAndBalance.php 1.5 KB

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