| | |
| | | class ExchangePosterForm extends GrafikaOption |
| | | { |
| | | public $code; |
| | | public $card_no; |
| | | |
| | | public function rules() |
| | | { |
| | | return [ |
| | | [['code'], 'required'], |
| | | [['code'], 'string'], |
| | | [['code','card_no'], 'string'], |
| | | ]; |
| | | } |
| | | |
| | |
| | | { |
| | | return ExchangeCode::find()->where([ |
| | | 'code' => $this->code, |
| | | 'card_no' => $this->card_no, |
| | | 'mall_id' => \Yii::$app->mall->id |
| | | ])->one(); |
| | | } |
| | |
| | | private $user_id = ''; |
| | | private $mall_id = ''; |
| | | private $library_id = ''; |
| | | private $card_no = ''; |
| | | |
| | | public function __construct(...$params) |
| | | { |
| | |
| | | $this->is_success = next($params); |
| | | $this->remake = next($params) ?: ''; |
| | | $this->library_id = next($params); |
| | | $this->card_no = next($params); |
| | | } |
| | | |
| | | |
| | |
| | | $model->origin = $this->origin; |
| | | $model->is_success = $this->is_success; |
| | | $model->code = $this->code; |
| | | $model->card_no = $this->card_no; |
| | | $model->remake = $this->remake; |
| | | $model->library_id = $this->library_id; |
| | | if (!$model->save()) { |
| | |
| | | $codeModel = ExchangeCode::find()->where([ |
| | | 'AND', |
| | | ['code' => $this->code], |
| | | ['card_no' => $this->card_no], |
| | | ['in', 'status', [2, 3]] |
| | | ])->one(); |
| | | if ($codeModel) { |
| | |
| | | $codeModel->name = $extra_info['name'] ?? ''; |
| | | $codeModel->mobile = $extra_info['mobile'] ?? ''; |
| | | $codeModel->save(); |
| | | $this->getLog($user, $codeModel->r_origin, $code, $codeModel->library_id); |
| | | $this->getLog($user, $codeModel->r_origin, $code, $codeModel->library_id,$codeModel->card_no); |
| | | } |
| | | |
| | | private function getLog($user, $origin, $code, $library_id) |
| | | private function getLog($user, $origin, $code, $library_id,$card_no) |
| | | { |
| | | $log = new CreatdCodeLog($user->mall_id, $user->id, $origin, $code, 1, '兑换记录成功', $library_id); |
| | | $log = new CreatdCodeLog($user->mall_id, $user->id, $origin, $code, 1, '兑换记录成功', $library_id,$card_no); |
| | | $log->save(); |
| | | } |
| | | } |
| | |
| | | try { |
| | | /** @var ExchangeCode $codeModel */ |
| | | $code = $info['code']; |
| | | $card_no = $info['card_no']; |
| | | $token = $info['token']; |
| | | |
| | | $codeModel = ExchangeCode::find()->where(['code' => $code])->one(); |
| | | $codeModel = ExchangeCode::find()->where(['code' => $code,'card_no'=>$card_no])->one(); |
| | | if (!$codeModel || !$token) { |
| | | throw new \Exception('警告'); |
| | | } |
| | |
| | | * @property string $remake 简单说明 |
| | | * @property string $created_at |
| | | * @property string $library_id |
| | | * @property string $card_no |
| | | */ |
| | | class ExchangeCodeLog extends ModelActiveRecord |
| | | { |
| | |
| | | [['mall_id', 'user_id', 'is_success', 'library_id'], 'integer'], |
| | | [['created_at'], 'safe'], |
| | | [['remake'], 'string'], |
| | | [['code', 'remake'], 'string', 'max' => 255], |
| | | [['code', 'remake','card_no'], 'string', 'max' => 255], |
| | | [['origin'], 'string', 'max' => 100], |
| | | ]; |
| | | } |
| | |
| | | 'remake' => '简单说明', |
| | | 'created_at' => 'Created At', |
| | | 'library_id' => 'library_id', |
| | | 'card_no' => '卡号', |
| | | ]; |
| | | } |
| | | } |