Commit 370c5794 authored by 侯贺政's avatar 侯贺政

添加新建运费模板

Signed-off-by: 侯贺政's avatarhouhezheng <houhezheng@romens.cn>
parent 4749f56f
......@@ -27,7 +27,7 @@ class TransportSettingController extends BaseController
* 运费模板列表:
* 运费模板所属平台,如果不填默认取微商城的运费模板",
* @OA\Parameter(name="page",in="query",description="分页页码",@OA\Schema(type="int")),
* @OA\Parameter(name="PLATFORM_TYPE",in="query",description="运费模板所属平台(微商城:shop,积分商城:points)",@OA\Schema(type="string")),
* @OA\Parameter(name="PLATFORM_TYPE",in="query",required=true,description="运费模板所属平台(微商城:shop,积分商城:points)",@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:运费模板GUID,
* TRANSPORT_NAME:配送方式,
......@@ -324,11 +324,103 @@ class TransportSettingController extends BaseController
if ($userInfo['ROLE_ID'] == USER_ROLE_REGION_ADMIN && ($userInfo['BRANCH_GUID'] != $_model['GROUP_GUID']) && ($userInfo['PARENT_BRANCH_GUID'] != $_model['GROUP_GUID'])) {
throw new BadRequestHttpException('不能删除总部或其他省级的运费模板!');
}
if (!$_model->delete()) {
throw new ServerErrorHttpException('删除失败!');
}
throw new HttpException(200, "删除成功!");
}
/**
* @OA\Post(
* path="/backend/web/v1/transport/transport-settings/transport-fee-add",
* tags={"配送管理"},
* summary="新建运费模板(侯贺政)",
* description="新建运费模板",
* @OA\RequestBody(
* required=true,
* description="注:门店编号、操作人工号、操作人姓名必填,且不能填入已存在评分的门店编码,其他根据需要选填。",
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* required={"PLATFORM_TYPE","TRANSPOR_TTYPE","IS_USED"},
* @OA\Property(property="PLATFORM_TYPE",type="sting",description="运费模板所属平台(默认微商城:shop,积分商城:points)",example="shop"),
* @OA\Property(property="TRANSPOR_TTYPE" ,type="string", description="配送方式(GUID)"),
* @OA\Property(property="BASE_FEE", type="float(18,2)",description="统一费用(元)"),
* @OA\Property(property="BASE_WEIGHT", type="string",description="首重(克)"),
* @OA\Property(property="BASE_WEIGHT_FEE", type="float(18,2)",description="首重费用(元)"),
* @OA\Property(property="INCREASE_WEIGHT", type="string",description="续重(克)"),
* @OA\Property(property="INCREASE_WEIGHT_FEE", type="float(18,2)",description="续重费用(元)"),
* @OA\Property(property="IS_USED", type="int",description="是否启用(默认启用)",example="1"),
* @OA\Property(property="DESCRIPTION", type="string",description="简介"),
* @OA\Property(property="LIMIT_MEMBER_GROUP_GUID", type="string",description="限制人群(GUID)"),
* @OA\Property(property="SELECT_AREA", type="string",description="配送城市(GUID)"),
* @OA\Property(property="BRANCHES_INFO", type="string",description="指定省级(GUID)"),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="OK,保存成功"
* ),
* security={{"Authorization":{}}}
* )
*/
public function actionTransportFeeAdd()
{
$params = Yii::$app->request->bodyParams;
$userInfo = (new ShopRbacUser)->getRbacUserInfo(Yii::$app->user->identity->GUID);
$model = new $this->modelClass();
$model->scenario = 'creation';
$model->attributes = [
"GUID" => Func::create_guid(),
"ORG_GUID" => Yii::$app->user->identity->ORG_GUID,
"TRANSPOR_TTYPE" => $params['TRANSPOR_TTYPE'],
"BASE_FEE" => is_numeric($params['BASE_FEE']) ? $params['BASE_FEE'] : 0,
"BASE_WEIGHT" => is_numeric($params['BASE_WEIGHT']) ? $params['BASE_WEIGHT'] : '0',
"BASE_WEIGHT_FEE" => is_numeric($params['BASE_WEIGHT_FEE']) ? $params['BASE_WEIGHT_FEE'] : 0,
"INCREASE_WEIGHT" => is_numeric($params['INCREASE_WEIGHT']) ? $params['INCREASE_WEIGHT'] : '0',
"INCREASE_WEIGHT_FEE" => is_numeric($params['INCREASE_WEIGHT_FEE']) ? $params['INCREASE_WEIGHT_FEE'] : 0,
"IS_USED" => is_null($params['IS_USED']) ? 1 : $params['IS_USED'],
"DESCRIPTION" => $params['DESCRIPTION'],
"LIMIT_MEMBER_GROUP_GUID" => $params['LIMIT_MEMBER_GROUP_GUID'],
"SELECT_AREA" => $params['SELECT_AREA'],
"GROUP_GUID" => $userInfo['BRANCH_GUID'],
"PLATFORM_TYPE" => empty($params['PLATFORM_TYPE']) ? 'shop' : $params['PLATFORM_TYPE'],
];
//开启事务
$packagingcostsBranches = new ShopPackagingcostsBranches();
$transaction = $packagingcostsBranches->getDb()->beginTransaction();
try {
//添加省级到数据库
if (!empty($params['BRANCHES_INFO'])) {
$branches = explode(',', $params['BRANCHES_INFO']);
foreach ($branches as $value) {
$branch_list[] = [
Func::create_guid(),
Yii::$app->user->identity->ORG_GUID,
$model->GUID,
$value,
'TRANSPORTFEE',
date('Y-m-d H:i:s')
];
}
$keys = ['GUID', 'ORG_GUID', 'ACTIVITY_GUID', 'BRANCH_GUID', 'ACTIVITY_TYPE', 'CREATE_TIME'];
$packagingcostsBranches->getDb()->createCommand()->batchInsert($packagingcostsBranches::tableName(), $keys, $branch_list)->execute();
}
$transaction->commit();
} catch (\Throwable $th) {
$transaction->rollBack();
throw new ServerErrorHttpException($th);
}
if (!$model->save()) {
Yii::$app->response->statusCode = 422;
return $model->errors;
}
throw new HttpException(200, "添加成功!");
}
}
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