Commit 1f107815 authored by 郭勇志's avatar 郭勇志

导入

parent 51510c89
...@@ -68,7 +68,7 @@ class O2oDeliveryController extends BaseController ...@@ -68,7 +68,7 @@ class O2oDeliveryController extends BaseController
->select('scds.GUID as SCDS_GUID ,sb.NAME as BRANCH_NAME,sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE') ->select('scds.GUID as SCDS_GUID ,sb.NAME as BRANCH_NAME,sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE')
->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID') ->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID')
->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID') ->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID')
->andFilterWhere(['scds.SETTING_TYPE'=>2])//设定为o2o配送 ->andFilterWhere(['scds.SETTING_TYPE'=>O2O_FLAG])//设定为o2o配送
->andFilterWhere(['or',['sb.CODE'=>$model->BRANCH_INFO],['like','sb.NAME',$model->BRANCH_INFO]]) ->andFilterWhere(['or',['sb.CODE'=>$model->BRANCH_INFO],['like','sb.NAME',$model->BRANCH_INFO]])
->andFilterWhere(['sb.GUID'=>$branchGuid]) ->andFilterWhere(['sb.GUID'=>$branchGuid])
->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid]) ->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid])
...@@ -137,7 +137,7 @@ class O2oDeliveryController extends BaseController ...@@ -137,7 +137,7 @@ class O2oDeliveryController extends BaseController
->select('scds.GUID as SCDS_GUID ,sb.NAME as BRANCH_NAME,sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE') ->select('scds.GUID as SCDS_GUID ,sb.NAME as BRANCH_NAME,sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE')
->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID') ->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID')
->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID') ->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID')
->andFilterWhere(['scds.SETTING_TYPE'=>2])//设定为o2o配送 ->andFilterWhere(['scds.SETTING_TYPE'=>O2O_FLAG])//设定为o2o配送
->andFilterWhere(['sb.GUID'=>$branchGuid]) ->andFilterWhere(['sb.GUID'=>$branchGuid])
->andFilterWhere(['scds.GUID'=>$model->GUID]) ->andFilterWhere(['scds.GUID'=>$model->GUID])
->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid]) ->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid])
...@@ -254,6 +254,7 @@ class O2oDeliveryController extends BaseController ...@@ -254,6 +254,7 @@ class O2oDeliveryController extends BaseController
if ($fileInfo['CODE']==200) { if ($fileInfo['CODE']==200) {
$rows = Helper::newSpreadsheet($fileInfo['INFO'][0])->getRows(); $rows = Helper::newSpreadsheet($fileInfo['INFO'][0])->getRows();
$tempArr=array_slice($rows,2); $tempArr=array_slice($rows,2);
$scdrModel = new ShopCityDistributionRegion();
$scdsModel = new $this->modelClass(); $scdsModel = new $this->modelClass();
$scdsModel->scenario = 'o2o_import'; $scdsModel->scenario = 'o2o_import';
//判断用户等级 //判断用户等级
...@@ -274,7 +275,36 @@ class O2oDeliveryController extends BaseController ...@@ -274,7 +275,36 @@ class O2oDeliveryController extends BaseController
$transaction=$scdsModel->getDb()->beginTransaction(); $transaction=$scdsModel->getDb()->beginTransaction();
try { try {
foreach ($tempArr as $key => $value) { foreach ($tempArr as $key => $value) {
$_scdsModel = $scdsModel::find()->where(['BRANCH_GUID'=>Yii::$app->user->identity->ORG_GUID.'-'.$value[0],'SETTING_TYPE'=>O2O_FLAG]);
if ($_scdsModel===null) {
$_scdsModel = clone $scdsModel;
}
$_scdsModel->BRANCH_CODE=$value[0];
$_scdsModel->REGION_TYPE=$value[1];
$_scdsModel->DELIVERY_PRICE=$value[2];
$_scdsModel->REGION_DISTR_DISTANCE=$value[3];
$_scdsModel->REGION_DISTR_PRICE=$value[4];
$_scdsModel->INCREASE_DISTANCE=$value[5];
$_scdsModel->INCREASE_PRICE=$value[6];
if ($_scdsModel->REGION_TYPE==1) {
$_scdrModel = $scdrModel::find()->where(['$_scdsModel'=>$_scdsModel->GUID]);
if ($_scdrModel===null) {
$_scdrModel = clone $scdrModel;
}
// $_scdrModel ->
if (!$_scdsModel->save()|| $_scdrModel->save(false)) {
$transaction->rollBack();
$returnInfo = [
($key+1) => $_scdsModel->errors
];
@unlink($fileInfo['INFO'][0]);
Yii::$app->response->statusCode = 422;
return $returnInfo; # code...
}
}elseif($_scdsModel->REGION_TYPE==2){
}
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
$transaction->rollBack(); $transaction->rollBack();
...@@ -328,7 +358,7 @@ class O2oDeliveryController extends BaseController ...@@ -328,7 +358,7 @@ class O2oDeliveryController extends BaseController
->select('sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE') ->select('sb.CODE as BRANCH_CODE,scds.REGION_TYPE,scdr.DELIVERY_PRICE,scds.REGION_DISTR_DISTANCE,scds.REGION_DISTR_PRICE,scds.INCREASE_DISTANCE,scds.INCREASE_PRICE')
->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID') ->leftjoin('shop_branch sb','sb.GUID=scds.BRANCH_GUID')
->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID') ->leftjoin('shop_city_distribution_region scdr','scdr.CITY_DISTR_GUID=scds.GUID')
->andFilterWhere(['scds.SETTING_TYPE'=>2])//设定为o2o配送 ->andFilterWhere(['scds.SETTING_TYPE'=>O2O_FLAG])//设定为o2o配送
->andFilterWhere(['or',['sb.CODE'=>$model->BRANCH_INFO],['like','sb.NAME',$model->BRANCH_INFO]]) ->andFilterWhere(['or',['sb.CODE'=>$model->BRANCH_INFO],['like','sb.NAME',$model->BRANCH_INFO]])
->andFilterWhere(['sb.GUID'=>$branchGuid]) ->andFilterWhere(['sb.GUID'=>$branchGuid])
->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid]) ->orFilterWhere(['sb.PARENTGUID'=>$parentBranchGuid])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment