MerchantsUserBalanceModel.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. // 商户用户分数
  5. class MerchantsUserBalanceModel extends Model {
  6. protected $connection = 'fortue_tiger';
  7. // 设置表名(不含前缀)
  8. protected $name = 'merchants_user_balance';
  9. // 定义主键(默认为id)
  10. protected $pk = 'id';
  11. // 设置自动写入时间戳
  12. protected $autoWriteTimestamp = true;
  13. // 设置字段类型
  14. protected $type = [
  15. 'id' => 'int', // 自增ID
  16. 'user_id' => 'int', // 用户ID
  17. 'app_id' => 'int', // 商家ID
  18. 'uname' => 'int', // 平台用户的id 必须唯一
  19. 'balance' => 'decimal', // 分数
  20. 'hash' => 'string', // 分数 校验
  21. 'create_time' => 'int', // 创建时间
  22. 'update_time' => 'int', // 更新时间
  23. ];
  24. public static function getUsersBalanceList($app_id, $user_ids) {
  25. $where = [];
  26. $where[] = ['app_id', '=', $app_id];
  27. $where[] = ['user_id', 'in', $user_ids];
  28. $list = self::where($where)->select()->toArray();
  29. $user_config = array_column($list, null, 'user_id');
  30. return $user_config;
  31. }
  32. }