|
|
@@ -25,79 +25,29 @@ use yii\base\Exception;
|
|
|
*/
|
|
|
class OrderDeleteForm extends Model
|
|
|
{
|
|
|
- public $sn;
|
|
|
- public $expressCompany;
|
|
|
- public $orderTrackNo;
|
|
|
- public $status;
|
|
|
- public $remark;
|
|
|
-
|
|
|
- public $type;
|
|
|
- public $addressId;
|
|
|
- public $payType;
|
|
|
- public $goodsId;
|
|
|
- public $goodsNum;
|
|
|
- public $payPassword;
|
|
|
-
|
|
|
- public $userName;
|
|
|
- public $consignee;
|
|
|
- public $acceptMobile;
|
|
|
- public $province;
|
|
|
- public $city;
|
|
|
- public $county;
|
|
|
- public $detailaddress;
|
|
|
-
|
|
|
- private $_address;
|
|
|
- private $_decAmount;
|
|
|
- private $_decPv;
|
|
|
- private $_freight;
|
|
|
- private $_payAmount;
|
|
|
- private $_orderGoods;
|
|
|
+ public $orderSn;
|
|
|
|
|
|
/**
|
|
|
* @var Order
|
|
|
*/
|
|
|
private $_model;
|
|
|
|
|
|
- public function init() {
|
|
|
- parent::init();
|
|
|
- $this->adminOperateLogger = new AdminOperate([
|
|
|
- 'fetchClass' => Order::class,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @inheritdoc
|
|
|
*/
|
|
|
public function rules()
|
|
|
{
|
|
|
return [
|
|
|
- [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'trim'],
|
|
|
- [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'required'],
|
|
|
- [['status'], 'isStatus'],
|
|
|
- // [['payPassword'], 'validatePassword'],
|
|
|
+ [['orderSn'], 'trim'],
|
|
|
+ [['orderSn'], 'required'],
|
|
|
+ [['orderSn'], 'checkOrderType'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
public function attributeLabels()
|
|
|
{
|
|
|
return [
|
|
|
- 'sn' => '订单号',
|
|
|
- 'expressCompany' => '快递公司',
|
|
|
- 'orderTrackNo' => '快递单号',
|
|
|
- 'status' => '状态',
|
|
|
- 'remark' => '备注',
|
|
|
- 'type' => '订单类型',
|
|
|
- 'addressId' => '收货地址',
|
|
|
- 'payType' => '支付方式',
|
|
|
- 'goodsId' => '商品ID',
|
|
|
- 'goodsNum' => '商品数量',
|
|
|
- 'userName' => '复消会员编号',
|
|
|
- 'consignee' => '收货人',
|
|
|
- 'acceptMobile' => '收货电话',
|
|
|
- 'province' => '省',
|
|
|
- 'city' => '市',
|
|
|
- 'county' => '区',
|
|
|
- 'detailaddress' => '收货详细地址',
|
|
|
+ 'orderSn' => '订单号',
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -125,61 +75,44 @@ class OrderDeleteForm extends Model
|
|
|
return array_merge($parentScenarios, $customScenarios);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 校验之前
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public function beforeValidate()
|
|
|
- {
|
|
|
- $parentValidate = parent::beforeValidate();
|
|
|
- if ($this->sn) {
|
|
|
- $this->_model = Order::findOne(['SN'=>$this->sn]);
|
|
|
- if (!$this->_model){
|
|
|
- $this->addError('sn', '订单不存在');
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- if ($this->scenario == 'adminDelivery'){
|
|
|
- if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['cancel']) {
|
|
|
- $this->addError('sn', '订单已取消不能发货');
|
|
|
- return false;
|
|
|
- }
|
|
|
- if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
|
|
|
- $this->addError('sn', '订单已删除不能发货');
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return $parentValidate;
|
|
|
- }
|
|
|
-
|
|
|
- public function returnOrder() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
// /**
|
|
|
- // * 校验支付密码
|
|
|
- // * @param $attribute
|
|
|
- // * @param $params
|
|
|
+ // * 校验之前
|
|
|
+ // * @return bool
|
|
|
// */
|
|
|
- // public function validatePassword($attribute, $params) {
|
|
|
- // if (!User::validatePayPassword(\Yii::$app->user->id, $this->payPassword)) {
|
|
|
- // $this->addError($attribute, '支付密码不正确');
|
|
|
+ // public function beforeValidate()
|
|
|
+ // {
|
|
|
+ // $parentValidate = parent::beforeValidate();
|
|
|
+ // if ($this->sn) {
|
|
|
+ // $this->_model = Order::findOne(['SN'=>$this->sn]);
|
|
|
+ // if (!$this->_model){
|
|
|
+ // $this->addError('sn', '订单不存在');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
// }
|
|
|
+ // if ($this->scenario == 'adminDelivery'){
|
|
|
+ // if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['cancel']) {
|
|
|
+ // $this->addError('sn', '订单已取消不能发货');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
|
|
|
+ // $this->addError('sn', '订单已删除不能发货');
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return $parentValidate;
|
|
|
// }
|
|
|
|
|
|
- /**
|
|
|
- * 判断收货地址是否存在
|
|
|
- * @param $attribute
|
|
|
- */
|
|
|
- public function isAddress($attribute){
|
|
|
- if (!$receiveAddress = ReceiveAddress::find()->where(' ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
|
|
|
- $this->addError($attribute, '收货地址不存在');
|
|
|
- } else {
|
|
|
- $this->_address = $receiveAddress;
|
|
|
+ public function returnOrder() {
|
|
|
+ if(!$this->validate()){
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 判断支付方式
|
|
|
* @param $attribute
|
|
|
@@ -191,6 +124,13 @@ class OrderDeleteForm extends Model
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 判断订单类型
|
|
|
+ public function checkOrderType($attribute) {
|
|
|
+
|
|
|
+ $this->addError($attribute, $this->orderSn);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验类型
|
|
|
* @param $attribute
|