diff --git a/app/common/repositories/user/UserExtractRepository.php b/app/common/repositories/user/UserExtractRepository.php index 93f8685..8a2fb36 100644 --- a/app/common/repositories/user/UserExtractRepository.php +++ b/app/common/repositories/user/UserExtractRepository.php @@ -98,25 +98,28 @@ class UserExtractRepository extends BaseRepository * @author Qinii * @day 2020-06-16 */ - public function create($user,$data) + public function create($user, $data) { - event('user.extract.before',compact('user','data')); - $userExtract = Db::transaction(function()use($user,$data){ - if($user['brokerage_price'] < (systemConfig('user_extract_min'))) - throw new ValidateException('可提现金额不足'); - if($data['extract_price'] < (systemConfig('user_extract_min'))) + event('user.extract.before', compact('user', 'data')); + $userExtract = Db::transaction(function () use ($user, $data) { + if ($user['hp_value'] < (systemConfig('user_extract_min'))) + throw new ValidateException('生命值不足,无法提现'); + + if ($user['brokerage_price'] < (systemConfig('user_extract_min'))) + throw new ValidateException('可提增值积分不足'); + if ($data['extract_price'] < (systemConfig('user_extract_min'))) throw new ValidateException('提现金额不得小于最低额度'); - if($user['brokerage_price'] < $data['extract_price']) + if ($user['brokerage_price'] < $data['extract_price']) throw new ValidateException('提现金额不足'); - if($data['extract_type'] == 3) { + if ($data['extract_type'] == 3) { $make = app()->make(WechatUserRepository::class); $openid = $make->idByOpenId((int)$user['wechat_user_id']); - if (!$openid){ + if (!$openid) { $openid = $make->idByRoutineId((int)$user['wechat_user_id']); - if(!$openid) throw new ValidateException('openID获取失败,请确认是微信用户'); + if (!$openid) throw new ValidateException('openID获取失败,请确认是微信用户'); } } - $brokerage_price = bcsub($user['brokerage_price'],$data['extract_price'],2); + $brokerage_price = bcsub($user['brokerage_price'], $data['extract_price'], 2); $user->brokerage_price = $brokerage_price; $user->save(); @@ -126,7 +129,7 @@ class UserExtractRepository extends BaseRepository return $this->dao->create($data); }); - event('user.extract',compact('userExtract')); + event('user.extract', compact('userExtract')); SwooleTaskService::admin('notice', [ 'type' => 'extract', 'title' => '您有一条新的提醒申请', @@ -134,25 +137,25 @@ class UserExtractRepository extends BaseRepository ]); } - public function switchStatus($id,$data) + public function switchStatus($id, $data) { $extract = $this->dao->getWhere(['extract_id' => $id]); $user = app()->make(UserRepository::class)->get($extract['uid']); - if(!$user) throw new ValidateException('用户不存在'); + if (!$user) throw new ValidateException('用户不存在'); $brokerage_price = 0; - if($data['status'] == -1) - $brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2); + if ($data['status'] == -1) + $brokerage_price = bcadd($user['brokerage_price'], $extract['extract_price'], 2); $type = systemConfig('sys_extension_type'); $ret = []; $service = null; $func = null; - if ($data['status'] == 1 && $extract['extract_type'] == 3 && in_array($type,[1,2])) { + if ($data['status'] == 1 && $extract['extract_type'] == 3 && in_array($type, [1, 2])) { $func = $type == 1 ? 'merchantPay' : 'companyPay'; $ret = [ 'sn' => $extract['extract_sn'], 'price' => $extract['extract_price'], - 'mark' => '企业付款给用户:'.$user->nickname, - 'batch_name' => '企业付款给用户:'.$user->nickname + 'mark' => '企业付款给用户:' . $user->nickname, + 'batch_name' => '企业付款给用户:' . $user->nickname ]; $openid = app()->make(WechatUserRepository::class)->idByOpenId((int)$user['wechat_user_id']); if ($openid) { @@ -162,22 +165,22 @@ class UserExtractRepository extends BaseRepository $routineOpenid = app()->make(WechatUserRepository::class)->idByRoutineId((int)$user['wechat_user_id']); if (!$routineOpenid) throw new ValidateException('非微信用户不支持付款到零钱'); $ret['openid'] = $routineOpenid; - $service = MiniProgramService::create(); + $service = MiniProgramService::create(); } } - Db::transaction(function()use($id,$data,$user,$brokerage_price,$ret,$service,$func){ - event('user.extractStatus.before',compact('id','data')); + Db::transaction(function () use ($id, $data, $user, $brokerage_price, $ret, $service, $func) { + event('user.extractStatus.before', compact('id', 'data')); if ($ret) $service->{$func}($ret); - if($brokerage_price){ + if ($brokerage_price) { $user->brokerage_price = $brokerage_price; $user->save(); } - $userExtract = $this->dao->update($id,$data); - event('user.extractStatus',compact('id','userExtract')); + $userExtract = $this->dao->update($id, $data); + event('user.extractStatus', compact('id', 'userExtract')); }); - Queue::push(SendSmsJob::class,['tempId' => 'EXTRACT_NOTICE', 'id' =>$id]); + Queue::push(SendSmsJob::class, ['tempId' => 'EXTRACT_NOTICE', 'id' => $id]); } public function createSn() @@ -190,6 +193,6 @@ class UserExtractRepository extends BaseRepository public function getHistoryBank($uid) { - return $this->dao->getSearch(['uid' => $uid,'extract_type' => 0])->order('create_time DESC')->field('real_name,bank_code,bank_address,bank_name')->find(); + return $this->dao->getSearch(['uid' => $uid, 'extract_type' => 0])->order('create_time DESC')->field('real_name,bank_code,bank_address,bank_name')->find(); } } diff --git a/app/common/repositories/user/UserLabelRepository.php b/app/common/repositories/user/UserLabelRepository.php index d05ef5e..7ff1218 100644 --- a/app/common/repositories/user/UserLabelRepository.php +++ b/app/common/repositories/user/UserLabelRepository.php @@ -16,7 +16,9 @@ namespace app\common\repositories\user; use app\common\dao\user\UserLabelDao; use app\common\repositories\BaseRepository; +use app\common\repositories\store\CityAreaRepository; use FormBuilder\Exception\FormBuilderException; +use app\controller\admin\store\StoreBrand; use FormBuilder\Factory\Elm; use FormBuilder\Form; use think\db\exception\DataNotFoundException; @@ -88,11 +90,10 @@ class UserLabelRepository extends BaseRepository $isCreate = is_null($id); $action = Route::buildUrl($isCreate ? 'systemUserLabelCreate' : 'systemUserLabelUpdate', $isCreate ? [] : compact('id'))->build(); - $area = [ - ['value' => '', 'label' => '全部'], - ['value' => 1, 'label' => '自营'], - ['value' => 0, 'label' => '非自营'], - ]; + $StoreBrand = new CityAreaRepository(); + + $where['parent_id'] = 0; + $area =$StoreBrand->getList($where); return Elm::createForm($action, [ @@ -117,8 +118,6 @@ class UserLabelRepository extends BaseRepository Elm::input('brand_id', '品牌')->required(), Elm::input('trade_id', '行业')->required(), - - ])->setTitle($isCreate ? '添加合作人' : '编辑合作人')->formData($formData); } diff --git a/app/common/repositories/user/UserRepository.php b/app/common/repositories/user/UserRepository.php index adf2841..3772d67 100644 --- a/app/common/repositories/user/UserRepository.php +++ b/app/common/repositories/user/UserRepository.php @@ -145,6 +145,7 @@ class UserRepository extends BaseRepository } return $options; }), + Elm::selectMultiple('label_id', '用户标签')->options(function () { $data = app()->make(UserLabelRepository::class)->allOptions(); $options = []; @@ -154,6 +155,9 @@ class UserRepository extends BaseRepository } return $options; }), + + + Elm::radio('status', '状态', 1)->options([ ['value' => 0, 'label' => '关闭'], ['value' => 1, 'label' => '开启'],