|
|
@@ -207,6 +207,7 @@ class DeclarationUpgradeForm extends Model
|
|
|
if(!$warehouse){
|
|
|
throw new Exception('地区暂时不支持配送,具体联系客服');
|
|
|
}
|
|
|
+
|
|
|
$upgradeType = $isObserve ? 1 : 2; // 1补差 2全额
|
|
|
$periodObj = Period::instance();
|
|
|
$nowPeriodNum = $periodObj->getNowPeriodNum();
|
|
|
@@ -236,10 +237,13 @@ class DeclarationUpgradeForm extends Model
|
|
|
$decOrderModel->CREATED_AT = Date::nowTime();
|
|
|
$decOrderModel->UPGRADE_TYPE = $upgradeType;
|
|
|
$decOrderModel->REMARK = $remark;
|
|
|
+ $decOrderModel->ORI_LV = $oriDecLv; // 变更前的级别
|
|
|
+ $decOrderModel->UPGRADE_LV = $this->decLv; // 变更后的级别
|
|
|
if(!$decOrderModel->save()){
|
|
|
$transaction->rollBack();
|
|
|
throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
|
|
|
}
|
|
|
+
|
|
|
$orderModel = new Order();
|
|
|
$orderModel->SN = 'OS'.$ord;
|
|
|
$orderModel->DEC_SN = 'DS'.$ord;
|
|
|
@@ -270,6 +274,7 @@ class DeclarationUpgradeForm extends Model
|
|
|
$transaction->rollBack();
|
|
|
throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
|
|
|
}
|
|
|
+
|
|
|
// 加入商品到订单商品表
|
|
|
foreach($this->_orderGoods as $key=>$value){
|
|
|
$this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
|
|
|
@@ -291,28 +296,6 @@ class DeclarationUpgradeForm extends Model
|
|
|
$transaction->rollBack();
|
|
|
throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
|
|
|
}
|
|
|
- // 加入商品到订单商品表
|
|
|
- foreach($this->_orderGoods as $key=>$value){
|
|
|
- $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
|
|
|
- $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
|
|
|
- }
|
|
|
- OrderGoods::batchInsert($this->_orderGoods);
|
|
|
- //写入收货地址信息
|
|
|
- $addressModel = new ReceiveAddress();
|
|
|
- $addressModel->USER_ID = $this->_insertUserId;
|
|
|
- $addressModel->USER_NAME = $this->insertUserName;
|
|
|
- $addressModel->CONSIGNEE = $this->consignee;
|
|
|
- $addressModel->MOBILE = $this->acceptMobile;
|
|
|
- $addressModel->PROVINCE = $this->province;
|
|
|
- $addressModel->CITY = $this->city;
|
|
|
- $addressModel->COUNTY = intval($this->county) ?? 0;
|
|
|
- $addressModel->ADDRESS = $this->address;
|
|
|
- $addressModel->IS_DEFAULT = 0;
|
|
|
- if(!$addressModel->save()){
|
|
|
- $transaction->rollBack();
|
|
|
- throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
|
|
|
- }
|
|
|
-
|
|
|
// 扣报单人现金钱包
|
|
|
Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'升级报单']);
|
|
|
// 为被升级人进行升级操作
|