JoinShop.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\api\model\service;
  3. use think\Model;
  4. class JoinShop extends Model
  5. {
  6. // 表名
  7. protected $name = 'service_join_shop';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. public static function getCount($params)
  14. {
  15. $params['state'] = 1;
  16. return self::where($params)->count();
  17. }
  18. public static function getApplyShop($params)
  19. {
  20. $list = self::where(['shop_id'=>$params['shop_id'],'state'=>$params['state']])->field('id,skill_id,skill_name,state')->order('id desc')->page($params['page'])->limit(10)->select();
  21. foreach ($list as $key=>$value)
  22. {
  23. $skillInfo = Skill::skillInfo($value['skill_id']);
  24. $list[$key]['skillInfo'] = $skillInfo;
  25. $list[$key]['skillScore'] = Skill::getSkillScore($value['skill_id']);
  26. }
  27. return $list;
  28. }
  29. /**
  30. * 审核
  31. * @param $get
  32. * @return bool
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @throws \think\exception\DbException
  36. */
  37. public static function check($get)
  38. {
  39. $info = self::where(['id'=>$get['id'],'state'=>0])->field('id,state,skill_id,shop_id')->find();
  40. if(!$info)
  41. {
  42. return false;
  43. }
  44. if($get['state'] == 1)
  45. {
  46. $update['shop_id'] = $info['shop_id'];
  47. $update['percent'] = $get['percent'];
  48. Shop::where('id',$info['shop_id'])->setInc('already_service_nums');
  49. \app\api\model\service\Skill::where(['id'=>$info['skill_id']])->update($update);
  50. }
  51. self::where(['id'=>$info['id']])->update(['state'=>$get['state']]);
  52. return true;
  53. }
  54. }