zm
2021-03-31 4829ff0e5b698aabc435c41d4b4091228448e497
提货bug修改
6 files modified
21 ■■■■ changed files
plugins/exchange/forms/api/ExchangePosterForm.php 4 ●●● patch | view | raw | blame | history
plugins/exchange/forms/exchange/CreatdCodeLog.php 3 ●●●●● patch | view | raw | blame | history
plugins/exchange/forms/exchange/ExchangeFactory.php 1 ●●●● patch | view | raw | blame | history
plugins/exchange/forms/exchange/core/Create.php 6 ●●●● patch | view | raw | blame | history
plugins/exchange/handlers/OrderCreatedHandler.php 3 ●●●● patch | view | raw | blame | history
plugins/exchange/models/ExchangeCodeLog.php 4 ●●● patch | view | raw | blame | history
plugins/exchange/forms/api/ExchangePosterForm.php
@@ -17,12 +17,13 @@
class ExchangePosterForm extends GrafikaOption
{
    public $code;
    public $card_no;
    public function rules()
    {
        return [
            [['code'], 'required'],
            [['code'], 'string'],
            [['code','card_no'], 'string'],
        ];
    }
@@ -49,6 +50,7 @@
    {
        return ExchangeCode::find()->where([
            'code' => $this->code,
            'card_no' => $this->card_no,
            'mall_id' => \Yii::$app->mall->id
        ])->one();
    }
plugins/exchange/forms/exchange/CreatdCodeLog.php
@@ -20,6 +20,7 @@
    private $user_id = '';
    private $mall_id = '';
    private $library_id = '';
    private $card_no = '';
    public function __construct(...$params)
    {
@@ -30,6 +31,7 @@
        $this->is_success = next($params);
        $this->remake = next($params) ?: '';
        $this->library_id = next($params);
        $this->card_no = next($params);
    }
@@ -41,6 +43,7 @@
        $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()) {
plugins/exchange/forms/exchange/ExchangeFactory.php
@@ -201,6 +201,7 @@
            $codeModel = ExchangeCode::find()->where([
                'AND',
                ['code' => $this->code],
                ['card_no' => $this->card_no],
                ['in', 'status', [2, 3]]
            ])->one();
            if ($codeModel) {
plugins/exchange/forms/exchange/core/Create.php
@@ -45,12 +45,12 @@
        $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();
    }
}
plugins/exchange/handlers/OrderCreatedHandler.php
@@ -33,9 +33,10 @@
            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('警告');
                }
plugins/exchange/models/ExchangeCodeLog.php
@@ -16,6 +16,7 @@
 * @property string $remake 简单说明
 * @property string $created_at
 * @property string $library_id
 * @property string $card_no
 */
class ExchangeCodeLog extends ModelActiveRecord
{
@@ -37,7 +38,7 @@
            [['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],
        ];
    }
@@ -57,6 +58,7 @@
            'remake' => '简单说明',
            'created_at' => 'Created At',
            'library_id' => 'library_id',
            'card_no' => '卡号',
        ];
    }
}