|
|
@@ -125,19 +125,14 @@ class ApproachOrderForm extends Model
|
|
|
*/
|
|
|
public function beforeValidate()
|
|
|
{
|
|
|
- LoggerTool::error(['UPOP - webhook: (beforeValidate 1).']);
|
|
|
$parentValidate = parent::beforeValidate();
|
|
|
if ($this->sn) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (beforeValidate 2).', $this->sn]);
|
|
|
$this->_model = ApproachOrder::findOne(['SN' => $this->sn]);
|
|
|
- LoggerTool::error(['UPOP - webhook: (beforeValidate 3).', $this->_model]);
|
|
|
if (!$this->_model) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (beforeValidate 4).', $this->_model]);
|
|
|
$this->addError('sn', '订单不存在');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
- LoggerTool::error(['UPOP - webhook: (beforeValidate 5).', $this->_model]);
|
|
|
return $parentValidate;
|
|
|
}
|
|
|
|
|
|
@@ -146,7 +141,6 @@ class ApproachOrderForm extends Model
|
|
|
* @param $attribute
|
|
|
*/
|
|
|
public function isAddress($attribute){
|
|
|
- LoggerTool::error(['UPOP - webhook: (isAddress 1).']);
|
|
|
if (!$receiveAddress = ReceiveAddress::find()->where('ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
|
|
|
$this->addError($attribute, '收货地址不存在');
|
|
|
} else {
|
|
|
@@ -156,7 +150,6 @@ class ApproachOrderForm extends Model
|
|
|
$this->_address = $receiveAddress;
|
|
|
}
|
|
|
}
|
|
|
- LoggerTool::error(['UPOP - webhook: (isAddress 2).']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -166,24 +159,20 @@ class ApproachOrderForm extends Model
|
|
|
*/
|
|
|
public function isPayType($attribute)
|
|
|
{
|
|
|
- LoggerTool::error(['UPOP - webhook: (isPayType 1).']);
|
|
|
if ($this->payType && !in_array($this->payType, array_values(ShopGoods::BANK_CODE))) {
|
|
|
$this->addError('支付方式错误');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
// 一个订单只能包含一类商品
|
|
|
$goods = ShopGoods::find()->select('ID,CATE_ID')->where(['in', 'ID', $this->goodsId])->andWhere(['STATUS' => 1])->asArray()->all();
|
|
|
if (!$goods) {
|
|
|
throw new Exception('商品已下架');
|
|
|
- return;
|
|
|
}
|
|
|
$goodsCategoryType = array_unique(array_column($goods, 'CATE_ID'));
|
|
|
if (count($goodsCategoryType) > 1) {
|
|
|
$this->addError($attribute, '订单不能包含多种商品分类');
|
|
|
return;
|
|
|
}
|
|
|
- LoggerTool::error(['UPOP - webhook: (isPayType 2).']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -192,13 +181,10 @@ class ApproachOrderForm extends Model
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public function isStatus($attribute){
|
|
|
- LoggerTool::error(['UPOP - webhook: (isStatus 1).', $this->status]);
|
|
|
if ($this->status && ($this->status != \Yii::$app->params['orderStatus']['notPaid']['value']) && ($this->status != \Yii::$app->params['orderStatus']['paid']['value'])) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (isStatus 2).']);
|
|
|
$this->addError($attribute, '订单状态类型错误');
|
|
|
throw new Exception('商品已下架');
|
|
|
}
|
|
|
- LoggerTool::error(['UPOP - webhook: (isStatus 3).']);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -250,7 +236,6 @@ class ApproachOrderForm extends Model
|
|
|
public function verifyPayUPOP(): ?bool
|
|
|
{
|
|
|
if (!$this->validate()) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (validate).']);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -263,7 +248,6 @@ class ApproachOrderForm extends Model
|
|
|
$this->_model->NOTE = json_encode($this->note);
|
|
|
$this->_model->PAY_AT = strtotime($this->note['pay_time']);
|
|
|
if (!$this->_model->save()) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (update).']);
|
|
|
throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
|
|
|
}
|
|
|
|
|
|
@@ -280,7 +264,6 @@ class ApproachOrderForm extends Model
|
|
|
$transaction->commit();
|
|
|
return true;
|
|
|
} catch (Exception $e) {
|
|
|
- LoggerTool::error(['UPOP - webhook: (exp).' . $e->getFile() . ' ' . $e->getMessage()]);
|
|
|
$transaction->rollBack();
|
|
|
$this->addError('edit', $e->getFile() . ' ' . $e->getMessage());
|
|
|
return null;
|