|
@@ -20,7 +20,6 @@ class Platform extends Base
|
|
|
'is_select_pay_rate' => 0,
|
|
|
'desc' => '',
|
|
|
'status' => 0,
|
|
|
- 'pay_title' => '',
|
|
|
'pay_list' => []
|
|
|
], 'post', 'trim');
|
|
|
|
|
@@ -31,41 +30,11 @@ class Platform extends Base
|
|
|
'is_select_pay_rate|是否开启支付渠道' => 'require|number|in:0,1',
|
|
|
'desc|描述' => 'max:255',
|
|
|
'status|状态' => 'number|in:0,1',
|
|
|
- 'pay_title|渠道名称' => 'requireIf:is_select_pay_rate,1|max:255',
|
|
|
'pay_list|渠道配置' => 'requireIf:is_select_pay_rate,1|array|max:100'
|
|
|
]);
|
|
|
if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
-
|
|
|
-// $platform_code = makeNo("PT");
|
|
|
-// $platform_name = isset($this->post['platform_name']) && $this->post['platform_name'] !=="" ? trim($this->post['platform_name']):"";
|
|
|
-// if($platform_name==""){
|
|
|
-// return error_show(1003,"参数platform_name不能为空");
|
|
|
-//
|
|
|
-// }
|
|
|
-// $is_exit= Db::name("platform")->where(["platform_name"=>$platform_name])->find();
|
|
|
-// if($is_exit){
|
|
|
-// return error_show(1003,"平台名称已存在");
|
|
|
-// }
|
|
|
-// $platform_type = isset($this->post['platform_type']) && $this->post['platform_type'] !=="" ? intval($this->post['platform_type']):"";
|
|
|
-// if($platform_type===""){
|
|
|
-// return error_show(1002,"参数platform_type不能为空");
|
|
|
-// }
|
|
|
-// $use_type = isset($this->post['use_type']) && $this->post['use_type'] !=="" ? intval($this->post['use_type']):"";
|
|
|
-// if($use_type===""){
|
|
|
-// return error_show(1002,"参数use_type不能为空");
|
|
|
-// }
|
|
|
-// $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
-// if($token==''){
|
|
|
-// return error_show(105,"参数token不能为空");
|
|
|
-// }
|
|
|
-// $user =GetUserInfo($token);
|
|
|
-// if(empty($user)||$user['code']!=0){
|
|
|
-// return error_show(1002,"创建人数据不存在");
|
|
|
-// }
|
|
|
$action_id = $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
$action_name = $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
-// $desc=isset($this->post['desc']) && $this->post['desc'] !=="" ? trim($this->post['desc']):"";
|
|
|
-// $status= isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"0";
|
|
|
|
|
|
Db::startTrans();
|
|
|
|
|
@@ -104,63 +73,20 @@ class Platform extends Base
|
|
|
$this->addPlat($platform_id);
|
|
|
|
|
|
if ($param['is_select_pay_rate'] == 1) {
|
|
|
-
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
-
|
|
|
-// if (!isset($company_names['code']) || $company_names['code'] != 0) throw new Exception($company_names['message']);
|
|
|
-
|
|
|
- $weight = 0;
|
|
|
- $insert_da = [[
|
|
|
- 'platform_id' => $platform_id,
|
|
|
- 'companyNo' => 'GYS',
|
|
|
- 'companyName' => '供应商',
|
|
|
- 'supplierName' => '',
|
|
|
- 'supplierNo' => '',
|
|
|
- 'rate' => 0,
|
|
|
- 'is_cgd' => 0,
|
|
|
- 'is_qrd' => 1,
|
|
|
- 'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
- 'is_del' => 0,
|
|
|
- "addtime" => $date,
|
|
|
- "updatetime" => $date
|
|
|
- ]];
|
|
|
+ $weight=0;
|
|
|
foreach ($param['pay_list'] as $pay) {
|
|
|
- $company_names = $userCommon->handle('hqInfo', ['code' =>$pay['companyNo']]);
|
|
|
$insert_da[] = [
|
|
|
'platform_id' => $platform_id,
|
|
|
- 'companyNo' => $pay['companyNo'],
|
|
|
- 'companyName' => $company_names['data']['name'] ?? '',
|
|
|
- 'supplierName' => $company_names['data']['relation_name'] ?? '',
|
|
|
- 'supplierNo' => $company_names['data']['relation_code'] ?? '',
|
|
|
- 'rate' => $pay['rate'],
|
|
|
- 'is_cgd' => 1,
|
|
|
- 'is_qrd' => 1,
|
|
|
+ 'channel_id' => $pay['channel_id'],
|
|
|
+ 'apply_id' => $this->uid,
|
|
|
+ 'apply_name' => $this->uname,
|
|
|
'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
'is_del' => 0,
|
|
|
"addtime" => $date,
|
|
|
"updatetime" => $date
|
|
|
];
|
|
|
}
|
|
|
-
|
|
|
- $insert_da[] = [
|
|
|
- 'platform_id' => $platform_id,
|
|
|
- 'companyNo' => 'KH',
|
|
|
- 'companyName' => '客户',
|
|
|
- 'supplierName' => '',
|
|
|
- 'supplierNo' => '',
|
|
|
- 'rate' => 0,
|
|
|
- 'is_cgd' => 0,
|
|
|
- 'is_qrd' => 0,
|
|
|
- 'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
- 'is_del' => 0,
|
|
|
- "addtime" => $date,
|
|
|
- "updatetime" => $date
|
|
|
- ];
|
|
|
-
|
|
|
- if ($insert_da) Db::name('platform_pay_rate')->insertAll($insert_da);
|
|
|
+ if ($insert_da) Db::name('platform_channel')->insertAll($insert_da);
|
|
|
}
|
|
|
// return error_show(0,"新建成功");
|
|
|
// }else{
|
|
@@ -280,51 +206,11 @@ class Platform extends Base
|
|
|
'is_select_pay_rate|是否开启支付渠道' => 'require|number|in:0,1',
|
|
|
'desc|描述' => 'max:255',
|
|
|
'status|状态' => 'number|in:0,1',
|
|
|
- 'pay_title|渠道名称' => 'requireIf:is_select_pay_rate,1|max:255',
|
|
|
'pay_list|渠道配置' => 'requireIf:is_select_pay_rate,1|array|max:100'
|
|
|
]);
|
|
|
|
|
|
if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
|
|
|
-// $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
|
|
|
-// if ($id == "") {
|
|
|
-// return error_show(1002, "参数id不能为空");
|
|
|
-// }
|
|
|
-// $info = Db::name("platform")->where(['id' => $id, "is_del" => 0])->find();
|
|
|
-// if ($info == "") {
|
|
|
-// return error_show(1002, "未找到数据");
|
|
|
-// }
|
|
|
-// $platform_code = makeNo("PT");
|
|
|
-// $platform_name = isset($this->post['platform_name']) && $this->post['platform_name'] !== "" ? trim($this->post['platform_name']) : "";
|
|
|
-// if ($platform_name == "") {
|
|
|
-// return error_show(1002, "参数platform_name不能为空");
|
|
|
-// }
|
|
|
-// $platform_type = isset($this->post['platform_type']) && $this->post['platform_type'] !== "" ? intval($this->post['platform_type']) :"";
|
|
|
-// if($platform_type===""){
|
|
|
-// return error_show(1002,"参数platform_type不能为空");
|
|
|
-// }
|
|
|
-// $use_type = isset($this->post['use_type']) && $this->post['use_type'] !=="" ? intval($this->post['use_type']):"";
|
|
|
-// if($use_type===""){
|
|
|
-// return error_show(1002,"参数use_type不能为空");
|
|
|
-// }
|
|
|
-// $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
|
|
|
-// if ($token == '') {
|
|
|
-// return error_show(1005, "参数token不能为空");
|
|
|
-// }
|
|
|
-// $is_exit= Db::name("platform")->where([["platform_name","=",$platform_name],["id","<>",$id]])->find();
|
|
|
-// if($is_exit){
|
|
|
-// return error_show(1003,"平台名称已存在");
|
|
|
-// }
|
|
|
-// $user = GetUserInfo($token);
|
|
|
-// if (empty($user) || $user['code'] != 0) {
|
|
|
-// return error_show(102, "创建人数据不存在");
|
|
|
-// }
|
|
|
-// $action_id = isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
-// $action_name = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
-// $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
|
|
|
-// $desc = isset($this->post['desc']) && $this->post['desc'] !== "" ? trim($this->post['desc']) : "";
|
|
|
-
|
|
|
-
|
|
|
Db::startTrans();
|
|
|
|
|
|
try {
|
|
@@ -343,21 +229,15 @@ class Platform extends Base
|
|
|
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
|
|
- $platform_code = makeNo("PT");
|
|
|
+// $platform_code = makeNo("PT");
|
|
|
|
|
|
$data = [
|
|
|
- "platform_code" => $platform_code,
|
|
|
"platform_name" => $param['platform_name'],
|
|
|
"platform_type" => $param['platform_type'],
|
|
|
"use_type" => $param['use_type'],
|
|
|
"desc" => $param['desc'],
|
|
|
-// "createrid" => $action_id,
|
|
|
-// "creater" => $action_name,
|
|
|
'is_select_pay_rate' => $param['is_select_pay_rate'],
|
|
|
- 'pay_title' => $param['pay_title'],
|
|
|
"status" => $param['status'],
|
|
|
-// "is_del" => 0,
|
|
|
-// "addtime" => $date,
|
|
|
"updatetime" => $date
|
|
|
];
|
|
|
Db::name("platform")->where(['is_del' => 0, 'id' => $param['id']])->update($data);
|
|
@@ -369,67 +249,22 @@ class Platform extends Base
|
|
|
ChangeLog::logAdd(8, $info['platform_code'], $jsp, $json, ['id' => $this->uid, 'nickname' => $this->uname]);
|
|
|
|
|
|
if ($param['is_select_pay_rate'] == 1) {
|
|
|
-
|
|
|
- $userCommon = \app\admin\common\User::getIns();
|
|
|
- $company_names = $userCommon->handle('getCodeAndName', ['code' => array_column($param['pay_list'], 'companyNo')]);
|
|
|
-
|
|
|
- Db::name('platform_pay_rate')
|
|
|
- ->where(['is_del' => 0, 'platform_id' => $param['id']])
|
|
|
- ->update(['is_del' => 1, 'updatetime' => $date]);
|
|
|
-
|
|
|
$weight = 0;
|
|
|
-
|
|
|
- $insert_da = [[
|
|
|
- 'platform_id' => $param['id'],
|
|
|
- 'companyNo' => 'GYS',
|
|
|
- 'companyName' => '供应商',
|
|
|
- 'supplierName' => '',
|
|
|
- 'supplierNo' => '',
|
|
|
- 'rate' => 0,
|
|
|
- 'is_cgd' => 0,
|
|
|
- 'is_qrd' => 1,
|
|
|
- 'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
- 'is_del' => 0,
|
|
|
- "addtime" => $date,
|
|
|
- "updatetime" => $date
|
|
|
- ]];
|
|
|
foreach ($param['pay_list'] as $pay) {
|
|
|
- $company_names = $userCommon->handle('hqInfo', ['code' =>$pay['companyNo']]);
|
|
|
- $insert_da[] = [
|
|
|
- 'platform_id' => $param['id'],
|
|
|
- 'companyNo' => $pay['companyNo'],
|
|
|
- 'companyName' => $company_names['data']['name'] ?? '',
|
|
|
- 'supplierName' => $company_names['data']['relation_name'] ?? '',
|
|
|
- 'supplierNo' => $company_names['data']['relation_code'] ?? '',
|
|
|
- 'rate' => $pay['rate'],
|
|
|
- 'is_cgd' => 1,
|
|
|
- 'is_qrd' => 1,
|
|
|
+ $insert_da = [
|
|
|
+ "id"=>$pay["id"]??null,
|
|
|
+ 'platform_id' => $info['id'],
|
|
|
+ 'channel_id' => $pay['channel_id'],
|
|
|
+ 'apply_id' => $this->uid,
|
|
|
+ 'apply_name' => $this->uname,
|
|
|
'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
- 'is_del' => 0,
|
|
|
+ 'is_del' => $pay['is_del']??0,
|
|
|
"addtime" => $date,
|
|
|
"updatetime" => $date
|
|
|
];
|
|
|
+ $up =Db::name("platform_channel")->save($insert_da);
|
|
|
+ if($up==false) throw new \Exception("平台渠道信息更新失败");
|
|
|
}
|
|
|
-
|
|
|
- $insert_da[] = [
|
|
|
- 'platform_id' => $param['id'],
|
|
|
- 'companyNo' => 'KH',
|
|
|
- 'companyName' => '客户',
|
|
|
- 'supplierName' => '',
|
|
|
- 'supplierNo' => '',
|
|
|
- 'rate' => 0,
|
|
|
- 'is_cgd' => 0,
|
|
|
- 'is_qrd' => 0,
|
|
|
- 'weight' => $weight++,
|
|
|
- 'status' => 1,
|
|
|
- 'is_del' => 0,
|
|
|
- "addtime" => $date,
|
|
|
- "updatetime" => $date
|
|
|
- ];
|
|
|
-
|
|
|
- if ($insert_da) Db::name('platform_pay_rate')->insertAll($insert_da);
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
@@ -479,9 +314,10 @@ class Platform extends Base
|
|
|
->find();
|
|
|
if (empty($info)) return error_show(1004, '未找到数据');
|
|
|
else {
|
|
|
- $info['pay_list'] = Db::name('platform_pay_rate')
|
|
|
- ->field('id,companyNo,companyName,rate,status')
|
|
|
- ->where(['platform_id' => $info['id'], 'is_del' => 0])
|
|
|
+ $info['pay_list'] = Db::name('platform_channel')->alias("a")
|
|
|
+ ->leftJoin("channel b","a.channel_id=b.id")
|
|
|
+ ->field('a.id,b.companyNo,b.companyName,b.channel_name,a.is_del')
|
|
|
+ ->where(['a.platform_id' => $info['id'], 'a.is_del' => 0,"b.is_del"=>0])
|
|
|
->order(['weight' => 'desc'])
|
|
|
->select()
|
|
|
->toArray();
|
|
@@ -525,12 +361,12 @@ class Platform extends Base
|
|
|
|
|
|
if ($rs == 0) throw new Exception('该平台不存在');
|
|
|
|
|
|
- Db::name('platform_pay_rate')
|
|
|
- ->where(['is_del' => 0, 'platform_id' => $id])
|
|
|
- ->update([
|
|
|
- 'is_del' => 1,
|
|
|
- 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
- ]);
|
|
|
+// Db::name('platform_pay_rate')
|
|
|
+// ->where(['is_del' => 0, 'platform_id' => $id])
|
|
|
+// ->update([
|
|
|
+// 'is_del' => 1,
|
|
|
+// 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
+// ]);
|
|
|
|
|
|
Db::commit();
|
|
|
|
|
@@ -586,13 +422,13 @@ class Platform extends Base
|
|
|
|
|
|
if ($rs == 0) throw new Exception('该平台不存在或重复操作');
|
|
|
|
|
|
- Db::name('platform_pay_rate')
|
|
|
- ->where(['is_del' => 0, 'platform_id' => $param['id']])
|
|
|
- ->where('status', '<>', $param['status'])
|
|
|
- ->update([
|
|
|
- 'status' => $param['status'],
|
|
|
- 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
- ]);
|
|
|
+// Db::name('platform_pay_rate')
|
|
|
+// ->where(['is_del' => 0, 'platform_id' => $param['id']])
|
|
|
+// ->where('status', '<>', $param['status'])
|
|
|
+// ->update([
|
|
|
+// 'status' => $param['status'],
|
|
|
+// 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
+// ]);
|
|
|
|
|
|
Db::commit();
|
|
|
|