|
|
@@ -56,6 +56,7 @@ class OrderForm extends Model
|
|
|
|
|
|
public $userName;
|
|
|
public $decUserName;
|
|
|
+ public $noLoginUserId;
|
|
|
public $consignee;
|
|
|
public $acceptMobile;
|
|
|
public $province;
|
|
|
@@ -96,7 +97,8 @@ class OrderForm extends Model
|
|
|
{
|
|
|
return [
|
|
|
[['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province'/*,'city','county'*/,'cityName','lgaName','detailaddress','email','decUserName'], 'trim'],
|
|
|
- [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','consignee','acceptMobile','province','city','county','detailaddress'/*,'email'*/,'decUserName'], 'required'],
|
|
|
+ [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum','consignee','acceptMobile','province','city','county','detailaddress'/*,'email'*/,'decUserName'], 'required'],
|
|
|
+ [['payPassword'], 'required', 'when' => function ($model) { return $model->scenario !== 'noLoginReconsumeOrder'; }],
|
|
|
[['status'], 'isStatus'],
|
|
|
[['addressId'], 'isAddress'],
|
|
|
[['payType'], 'isPayType'],
|
|
|
@@ -152,6 +154,7 @@ class OrderForm extends Model
|
|
|
'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'remark', 'payPassword', 'period'],
|
|
|
// 帮会员复消下单
|
|
|
'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province','cityName','lgaName','detailaddress','decUserName'],
|
|
|
+ 'noLoginReconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark','consignee','acceptMobile','province','cityName','lgaName','detailaddress','decUserName'],
|
|
|
// 管理员退款
|
|
|
'adminRefund' => ['sn'],
|
|
|
// AMP
|
|
|
@@ -817,6 +820,11 @@ class OrderForm extends Model
|
|
|
* @throws Exception
|
|
|
* @throws \yii\db\Exception
|
|
|
*/
|
|
|
+ private function getReconsumeActorId()
|
|
|
+ {
|
|
|
+ return $this->scenario === 'noLoginReconsumeOrder' ? $this->noLoginUserId : \Yii::$app->user->id;
|
|
|
+ }
|
|
|
+
|
|
|
public function reconsumeAdd(){
|
|
|
if(!$this->validate()){
|
|
|
return null;
|
|
|
@@ -839,16 +847,17 @@ class OrderForm extends Model
|
|
|
}
|
|
|
|
|
|
// 报单中心汇率
|
|
|
- $decCountryId = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
|
|
|
+ $reconsumeActorId = $this->getReconsumeActorId();
|
|
|
+ $decCountryId = User::getEnCodeInfo($reconsumeActorId)['COUNTRY_ID'];
|
|
|
$decCountry = Countries::getById($decCountryId);
|
|
|
$decUserCurrencyRate = CurrencyConversions::getToUSDRate($decCountry['LOCAL_CURRENCY_ID']);
|
|
|
// 会员汇率
|
|
|
$country = Countries::getById($user['COUNTRY_ID']);
|
|
|
$currencyRate = CurrencyConversions::getToUSDRate($country['LOCAL_CURRENCY_ID']);
|
|
|
//判断是否是报单中心
|
|
|
- $loginUser = User::getEnCodeInfo(\Yii::$app->user->id);
|
|
|
+ $loginUser = User::getEnCodeInfo($reconsumeActorId);
|
|
|
if($loginUser['IS_DEC'] == 1){
|
|
|
- if($decUserID != \Yii::$app->user->id){
|
|
|
+ if($decUserID != $reconsumeActorId){
|
|
|
throw new Exception(Yii::t('app', 'decUserNameIsWrong'));
|
|
|
}
|
|
|
}
|
|
|
@@ -975,7 +984,7 @@ class OrderForm extends Model
|
|
|
$db = \Yii::$app->db;
|
|
|
$transaction = $db->beginTransaction();
|
|
|
try {
|
|
|
- $loginUserId = \Yii::$app->user->id;
|
|
|
+ $loginUserId = $reconsumeActorId;
|
|
|
|
|
|
//是否开启伞下会员限制
|
|
|
// $isResaleUmbrella = Cache::getSystemConfig()['isResaleUmbrella']['VALUE'];
|
|
|
@@ -1060,7 +1069,7 @@ class OrderForm extends Model
|
|
|
$nowPeriodNum = $periodObj->getNowPeriodNum();
|
|
|
$nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
|
|
|
//帮复消会员Id(登陆会员)
|
|
|
- $loginUserId = \Yii::$app->user->id;
|
|
|
+ $loginUserId = $this->getReconsumeActorId();
|
|
|
$loginUserName = Info::getUserNameByUserId($loginUserId);
|
|
|
//订单会员Id
|
|
|
$userId = Info::getUserIdByUserName($this->userName);
|