id,$this->authStore)){ $store = Store::find() ->where(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED]) ->one(); if (empty($store)) { \Yii::$app->response->data = ['code' => 1, 'msg' => '您非门店身份']; \Yii::$app->response->send(); return; } $this->store_id = $store->id; } return $action; } /** * 商户号设置 * * @return void */ public function actionYinDian() { if ($this->request->isGet) { $service = new MerchantService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]); $tips = \Yii::$app->services->setting->addons->get($this->mall_id, StoreEnum::ADDONS_NAME, 'tips'); return $this->success('获取成功', [ 'setting' => $service->getSetting(), 'link' => $service->getSignLink(), 'link_tips' => $tips['link_tips'] ?? '此链接用作申请银典子商户号,子商户号用作接收用户贷款,请您务必进行账号申请;进行账号申请后,请将申请的商户编号填入下方,为确保交易无误,请确保填入的商户号无误!否则因为填写错误造成的损失将由您自行承担!', 'bank_account_tips' => $tips['bank_account_tips'] ?? '用于快速到账,银行卡账户账户必须是和商户编号对应的账号,如填写错误会导致无法快速到账' ]); } if ($this->request->isPost) { $setting = $this->request->post(); // 数据校验 $res = \Yii::$app->services->validate->validate($setting, [ [['mcht_cd','bank_account', 'name', 'bank_account_type'], 'required'], [['bank_account_type'], 'integer'], ], [ 'mcht_cd' => '商户号', 'bank_account' => '银行账户', 'name' => '账户名称', 'bank_account_type' => '账户类型', ]); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $service = new MerchantService(['mall_id' => $this->mall_id, 'store_id' => $this->store_id]); return $service->setSetting($setting) ? $this->success('设置成功') : $this->error('保存失败'); } } public function actionReduceProfit() { $service = new MerchantReduceProfitService(); $setting = $service->profit($this->mall_id, $this->user_id, $this->store_id); if ($this->request->isGet) { return $this->success('获取成功', $setting); } if ($this->request->isPost) { $params = $this->request->post(); // 数据校验 $res = \Yii::$app->services->validate->validate($params, [ [['new_rate'], 'required'], [['new_rate'], 'number'], ], [ 'new_rate' => '让利百分比', ]); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); // 校验 if ($params['new_rate'] < $setting['min'] || $params['new_rate'] > $setting['max']) { return $this->error("让利百分比必须在 {$setting['min']} - {$setting['max']} 之间"); } $ret = $service->save($this->mall_id, $this->user_id, $this->store_id, $params['new_rate']); return is_string($ret) ? $this->error($ret) : $this->success('提交成功'); } } }