Commit 243122e0 authored by 孙磊's avatar 孙磊

Merge branch 'development' of http://gitlab-ebiz.yiyao365.cn/newshop/newshopback into development

parents 3a2ce10c 8dc0dbed
...@@ -249,6 +249,7 @@ return [ ...@@ -249,6 +249,7 @@ return [
], ],
'extraPatterns'=>[ 'extraPatterns'=>[
'GET,OPTIONS o2o-delivery-list' => 'o2o-delivery-list', 'GET,OPTIONS o2o-delivery-list' => 'o2o-delivery-list',
'PUT,OPTIONS o2o-delivery-update' => 'o2o-delivery-update',
], ],
], ],
//配送方式 //配送方式
......
...@@ -4,7 +4,7 @@ namespace backend\controllers\v1\transport; ...@@ -4,7 +4,7 @@ namespace backend\controllers\v1\transport;
use backend\controllers\v1\BaseController; use backend\controllers\v1\BaseController;
use Yii; use Yii;
use app\models\v1\rbacuser\ShopRbacUser; use app\models\v1\rbacuser\ShopRbacUser;
use yii\data\ActiveDataProvider; use yii\data\ArrayDataProvider;
use app\models\v1\branch\ShopCityDistributionRegion; use app\models\v1\branch\ShopCityDistributionRegion;
use yii\web\HttpException; use yii\web\HttpException;
...@@ -39,8 +39,8 @@ class O2oDeliveryController extends BaseController ...@@ -39,8 +39,8 @@ class O2oDeliveryController extends BaseController
{ {
$get = Yii::$app->request->get(); $get = Yii::$app->request->get();
$model = new $this->modelClass; $model = new $this->modelClass;
$model->attributes = $get;
$model->scenario='search'; $model->scenario='search';
$model->attributes = $get;
$model->GUID = isset($get['SCDS_GUID'])?$get['SCDS_GUID']:''; $model->GUID = isset($get['SCDS_GUID'])?$get['SCDS_GUID']:'';
if ($model->validate()) { if ($model->validate()) {
$rbacModel = new ShopRbacUser(); $rbacModel = new ShopRbacUser();
...@@ -60,9 +60,9 @@ class O2oDeliveryController extends BaseController ...@@ -60,9 +60,9 @@ class O2oDeliveryController extends BaseController
$parentBranchGuid=''; $parentBranchGuid='';
break; break;
} }
$query = $model->find() $infoArr = $model->find()
->alias('scds') ->alias('scds')
->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'=>2])//设定为o2o配送
...@@ -70,12 +70,12 @@ class O2oDeliveryController extends BaseController ...@@ -70,12 +70,12 @@ class O2oDeliveryController extends BaseController
->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])
->asArray(); ->asArray()->all();
return new ActiveDataProvider( return new ArrayDataProvider(
[ [
'query' => $query, 'allModels' => $infoArr,
'pagination' => [ 'pagination' => [
'pageSize'=>PAGE_SIZE, 'pageSize'=>1,
] ]
] ]
); );
...@@ -96,6 +96,7 @@ class O2oDeliveryController extends BaseController ...@@ -96,6 +96,7 @@ class O2oDeliveryController extends BaseController
* mediaType="application/x-www-form-urlencoded", * mediaType="application/x-www-form-urlencoded",
* @OA\Schema( * @OA\Schema(
* type="object", * type="object",
* required={"GUID","REGION_TYPE"},
* @OA\Property(property="GUID",description="列表接口返回的电子围栏设置GUID",type="string"), * @OA\Property(property="GUID",description="列表接口返回的电子围栏设置GUID",type="string"),
* @OA\Property(property="REGION_TYPE",description="列表接口返回收费方式",type="int"), * @OA\Property(property="REGION_TYPE",description="列表接口返回收费方式",type="int"),
* @OA\Property(property="DELIVERY_PRICE",description="区域运费",type="float"), * @OA\Property(property="DELIVERY_PRICE",description="区域运费",type="float"),
...@@ -112,30 +113,40 @@ class O2oDeliveryController extends BaseController ...@@ -112,30 +113,40 @@ class O2oDeliveryController extends BaseController
* */ * */
public function actionO2oDeliveryUpdate() public function actionO2oDeliveryUpdate()
{ {
$post = Yii::$app->request->post(); $put = Yii::$app->request->bodyParams;
$model = new $this->modelClass; $model = new $this->modelClass;
var_dump( $model->attributes);exit;
$model->attributes=$post;
$scdrModel = new ShopCityDistributionRegion();
$model->scenario='o2o_update'; $model->scenario='o2o_update';
$model->load($put,'');
$scdrModel = new ShopCityDistributionRegion();
if ($model->validate()) { if ($model->validate()) {
if ($model->REGION_TYPE==1) {//按区域 if ($model->REGION_TYPE==1) {//按区域
$_scdrModel = $scdrModel->find()->where(['CITY_DISTR_GUID'=>$model->GUID]);
$_scdrModel = $scdrModel->find()->where(['CITY_DISTR_GUID'=>$model->GUID])->one();
if (empty($_scdrModel)) { if (empty($_scdrModel)) {
throw new HttpException("404", '此条数据不存在'); throw new HttpException("404", '此条数据不存在');
}else{ }else{
$_scdrModel->attributes= $post; $_scdrModel->DELIVERY_PRICE= $model->DELIVERY_PRICE;
$_scdrModel->save(false); if ($_scdrModel->save(false)) {
throw new HttpException(200,'更新成功');
}else{
throw new HttpException(500,'更新失败');
}
} }
}elseif($model->REGION_TYPE==2){//按距离 }elseif($model->REGION_TYPE==2){//按距离
$_model=$model->findOne($post['GUID']); $_model=$model->findOne($model->GUID);
if (empty($_model)) { if (empty($_model)) {
throw new HttpException("404", '此条数据不存在'); throw new HttpException("404", '此条数据不存在');
}else{ }else{
$_model->save(false); $_model->REGION_DISTR_DISTANCE=$model->REGION_DISTR_DISTANCE;
$_model->REGION_DISTR_PRICE=$model->REGION_DISTR_PRICE;
$_model->INCREASE_DISTANCE=$model->INCREASE_DISTANCE;
$_model->INCREASE_PRICE=$model->INCREASE_PRICE;
if ($_model->save(false)) {
throw new HttpException(200,'更新成功');
}else{
throw new HttpException(500,'更新失败');
}
} }
} }
}else{ }else{
......
...@@ -42,6 +42,8 @@ class ShopCityDistributionSetting extends BaseModel ...@@ -42,6 +42,8 @@ class ShopCityDistributionSetting extends BaseModel
{ {
// 输入的门店编码或者门店名称 // 输入的门店编码或者门店名称
public $BRANCH_INFO; public $BRANCH_INFO;
// 区域运费
public $DELIVERY_PRICE;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -57,11 +59,19 @@ class ShopCityDistributionSetting extends BaseModel ...@@ -57,11 +59,19 @@ class ShopCityDistributionSetting extends BaseModel
{ {
return [ return [
[['ORG_GUID','GUID','BRANCH_GUID','REGION_TYPE','SETTING_TYPE'], 'required','on'=>['insert','update']], [['ORG_GUID','GUID','BRANCH_GUID','REGION_TYPE','SETTING_TYPE'], 'required','on'=>['insert','update']],
[['REGION_DISTR_DISTANCE', 'REGION_DISTR_PRICE','INCREASE_DISTANCE','INCREASE_PRICE'], 'double'],
[['STATUS'], 'boolean'], [['STATUS'], 'boolean'],
[['REGION_TYPE','SETTING_TYPE'], 'in', 'range' => [1, 2],'on'=>['insert','update']], [['REGION_TYPE','SETTING_TYPE'], 'in', 'range' => [1, 2],'on'=>['insert','update']],
[['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']], [['BRANCH_GUID'], 'exist', 'skipOnError' => true, 'targetClass' => ShopBranch::className(), 'targetAttribute' => ['BRANCH_GUID' => 'GUID']],
[['BRANCH_INFO'],'match', 'pattern' => '/^[0-9a-zA-Z_\x{4e00}-\x{9fa5}]+$/u','message'=>'只能包含中文汉字,字母,数字','on' => 'search'] [['BRANCH_INFO'],'match', 'pattern' => '/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u','message'=>'只能包含中文汉字,字母,数字','on' => 'search'],
[['GUID','REGION_TYPE'], 'required','on'=>['o2o_update'],'message'=>'{attribute}不能为空'],
[['REGION_DISTR_DISTANCE', 'REGION_DISTR_PRICE','INCREASE_DISTANCE','INCREASE_PRICE','DELIVERY_PRICE'], 'double','on'=>['o2o_update']],
[['REGION_DISTR_DISTANCE', 'REGION_DISTR_PRICE','INCREASE_DISTANCE','INCREASE_PRICE'], 'required','on'=>['o2o_update'],'when' => function($model) {
return $model->REGION_TYPE == '2';
},'message' => '{attribute}不能为空'],
[['DELIVERY_PRICE'], 'required','on'=>['o2o_update'],'when' => function($model) {
return $model->REGION_TYPE == '1';
},'message' => '{attribute}不能为空'],
]; ];
} }
...@@ -71,22 +81,23 @@ class ShopCityDistributionSetting extends BaseModel ...@@ -71,22 +81,23 @@ class ShopCityDistributionSetting extends BaseModel
public function attributeLabels() public function attributeLabels()
{ {
return [ return [
'GUID' => 'Guid', 'DELIVERY_PRICE' => '配送价格',
'GUID' => '主键GUID',
'ORG_GUID' => 'Org Guid', 'ORG_GUID' => 'Org Guid',
'BRANCH_GUID' => 'Branch Guid', 'BRANCH_GUID' => 'Branch Guid',
'IS_OWN_DISTR' => 'Is Own Distr', 'IS_OWN_DISTR' => 'Is Own Distr',
'IS_OTHER_DISTR' => 'Is Other Distr', 'IS_OTHER_DISTR' => 'Is Other Distr',
'WORK_TYPE' => 'Work Type', 'WORK_TYPE' => 'Work Type',
'IS_DADA_DISTR' => 'Is Dada Distr', 'IS_DADA_DISTR' => 'Is Dada Distr',
'REGION_TYPE' => 'Region Type', 'REGION_TYPE' => '配送类型',
'SIMPLE_DISTR_NOTES' => 'Simple Distr Notes', 'SIMPLE_DISTR_NOTES' => 'Simple Distr Notes',
'SIMPLE_DISTR_PIC' => 'Simple Distr Pic', 'SIMPLE_DISTR_PIC' => 'Simple Distr Pic',
'SIMPLE_DISTR_INITIAL_PRICE' => 'Simple Distr Initial Price', 'SIMPLE_DISTR_INITIAL_PRICE' => 'Simple Distr Initial Price',
'SIMPLE_DISTR_DELIVERY_PRICE ' => 'Simple Distr Delivery Price', 'SIMPLE_DISTR_DELIVERY_PRICE ' => 'Simple Distr Delivery Price',
'REGION_DISTR_DISTANCE' => 'Region Distr Distance', 'REGION_DISTR_DISTANCE' => '不同距离不同配送费**公里内数值',
'REGION_DISTR_PRICE' => 'Region Distr Price', 'REGION_DISTR_PRICE' => '不同距离不同配送费*公里内*元数值',
'INCREASE_DISTANCE' => 'Increase Distance', 'INCREASE_DISTANCE' => '不同距离不同配送费增加*公里数值',
'INCREASE_PRICE' => 'Increase Price', 'INCREASE_PRICE' => '不同距离不同配送费增加*公里*元数值',
'LAT' => 'Lat', 'LAT' => 'Lat',
'LNG' => 'Lng', 'LNG' => 'Lng',
'ADDRESS' => 'Address', 'ADDRESS' => 'Address',
......
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