| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\api\model\service;
- use think\Model;
- class JoinShop extends Model
- {
- // 表名
- protected $name = 'service_join_shop';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public static function getCount($params)
- {
- $params['state'] = 1;
- return self::where($params)->count();
- }
- public static function getApplyShop($params)
- {
- $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();
- foreach ($list as $key=>$value)
- {
- $skillInfo = Skill::skillInfo($value['skill_id']);
- $list[$key]['skillInfo'] = $skillInfo;
- $list[$key]['skillScore'] = Skill::getSkillScore($value['skill_id']);
- }
- return $list;
- }
- /**
- * 审核
- * @param $get
- * @return bool
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public static function check($get)
- {
- $info = self::where(['id'=>$get['id'],'state'=>0])->field('id,state,skill_id,shop_id')->find();
- if(!$info)
- {
- return false;
- }
- if($get['state'] == 1)
- {
- $update['shop_id'] = $info['shop_id'];
- $update['percent'] = $get['percent'];
- Shop::where('id',$info['shop_id'])->setInc('already_service_nums');
- \app\api\model\service\Skill::where(['id'=>$info['skill_id']])->update($update);
- }
- self::where(['id'=>$info['id']])->update(['state'=>$get['state']]);
- return true;
- }
- }
|