|
@@ -89,7 +89,7 @@ class CompanyPlatformCatProfit extends Base
|
|
|
'money_rate' => $param['money_rate'],
|
|
|
'low_rate' => $param['low_rate'],
|
|
|
'sale_rate' => $param['sale_rate'],
|
|
|
- 'status' => 0,
|
|
|
+ 'status' => 1,
|
|
|
'is_del' => 0,
|
|
|
'addtime' => $date,
|
|
|
'updatetime' => $date,
|
|
@@ -110,61 +110,61 @@ class CompanyPlatformCatProfit extends Base
|
|
|
}
|
|
|
|
|
|
//启禁用
|
|
|
- public function status()
|
|
|
- {
|
|
|
- $param = $this->request->only(['cat_id', 'companyNo', 'platform_id', 'status'], 'post', 'trim');
|
|
|
-
|
|
|
- $val = Validate::rule([
|
|
|
- 'cat_id|分类id' => 'require|number|gt:0',
|
|
|
- 'platform_id|平台id' => 'require|number|gt:0',
|
|
|
- 'companyNo|公司编码' => 'require|length:18',
|
|
|
- 'status|状态' => 'require|number|in:0,1',
|
|
|
- ]);
|
|
|
-
|
|
|
- if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
-
|
|
|
- $cat = Db::name('cat')
|
|
|
- ->field('id,level')
|
|
|
- ->where(['id' => $param['cat_id'], 'is_del' => 0])
|
|
|
- ->findOrEmpty();
|
|
|
-
|
|
|
- if (empty($cat)) return json_show(1005, '该分类不存在');
|
|
|
-
|
|
|
- //要操作的分类id集合
|
|
|
- switch ($cat['level']) {
|
|
|
- case 1:
|
|
|
- $first_ids = Db::name('cat')
|
|
|
- ->where(['is_del' => 0, 'pid' => $param['cat_id']])
|
|
|
- ->column('id');
|
|
|
-
|
|
|
- $second_ids = Db::name('cat')
|
|
|
- ->where('is_del', 0)
|
|
|
- ->whereIn('pid', $first_ids)
|
|
|
- ->column('id');
|
|
|
-
|
|
|
- $cat_ids = array_merge($first_ids, $second_ids);
|
|
|
- break;
|
|
|
-
|
|
|
- case 2:
|
|
|
- $cat_ids = Db::name('cat')
|
|
|
- ->where(['is_del' => 0, 'pid' => $param['cat_id']])
|
|
|
- ->column('id');
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- $cat_ids[] = $param['cat_id'];
|
|
|
-
|
|
|
- $rs = Db::name('company_platform_cat_profit')
|
|
|
- ->where(['is_del' => 0, 'companyNo' => $param['companyNo'], 'platform_id' => $param['platform_id']])
|
|
|
- ->whereIn('cat_id', $cat_ids)
|
|
|
- ->where('status', '<>', $param['status'])
|
|
|
- ->update([
|
|
|
- 'status' => $param['status'],
|
|
|
- 'updatetime' => date('Y-m-d H:i:s')
|
|
|
- ]);
|
|
|
- return $rs ? json_show(0, '操作成功') : json_show(1004, '操作失败,该记录不存在或重复操作');
|
|
|
-
|
|
|
- }
|
|
|
+// public function status()
|
|
|
+// {
|
|
|
+// $param = $this->request->only(['cat_id', 'companyNo', 'platform_id', 'status'], 'post', 'trim');
|
|
|
+//
|
|
|
+// $val = Validate::rule([
|
|
|
+// 'cat_id|分类id' => 'require|number|gt:0',
|
|
|
+// 'platform_id|平台id' => 'require|number|gt:0',
|
|
|
+// 'companyNo|公司编码' => 'require|length:18',
|
|
|
+// 'status|状态' => 'require|number|in:0,1',
|
|
|
+// ]);
|
|
|
+//
|
|
|
+// if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
+//
|
|
|
+// $cat = Db::name('cat')
|
|
|
+// ->field('id,level')
|
|
|
+// ->where(['id' => $param['cat_id'], 'is_del' => 0])
|
|
|
+// ->findOrEmpty();
|
|
|
+//
|
|
|
+// if (empty($cat)) return json_show(1005, '该分类不存在');
|
|
|
+//
|
|
|
+// //要操作的分类id集合
|
|
|
+// switch ($cat['level']) {
|
|
|
+// case 1:
|
|
|
+// $first_ids = Db::name('cat')
|
|
|
+// ->where(['is_del' => 0, 'pid' => $param['cat_id']])
|
|
|
+// ->column('id');
|
|
|
+//
|
|
|
+// $second_ids = Db::name('cat')
|
|
|
+// ->where('is_del', 0)
|
|
|
+// ->whereIn('pid', $first_ids)
|
|
|
+// ->column('id');
|
|
|
+//
|
|
|
+// $cat_ids = array_merge($first_ids, $second_ids);
|
|
|
+// break;
|
|
|
+//
|
|
|
+// case 2:
|
|
|
+// $cat_ids = Db::name('cat')
|
|
|
+// ->where(['is_del' => 0, 'pid' => $param['cat_id']])
|
|
|
+// ->column('id');
|
|
|
+// break;
|
|
|
+// }
|
|
|
+//
|
|
|
+// $cat_ids[] = $param['cat_id'];
|
|
|
+//
|
|
|
+// $rs = Db::name('company_platform_cat_profit')
|
|
|
+// ->where(['is_del' => 0, 'companyNo' => $param['companyNo'], 'platform_id' => $param['platform_id']])
|
|
|
+// ->whereIn('cat_id', $cat_ids)
|
|
|
+// ->where('status', '<>', $param['status'])
|
|
|
+// ->update([
|
|
|
+// 'status' => $param['status'],
|
|
|
+// 'updatetime' => date('Y-m-d H:i:s')
|
|
|
+// ]);
|
|
|
+// return $rs ? json_show(0, '操作成功') : json_show(1004, '操作失败,该记录不存在或重复操作');
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
//删除
|
|
|
public function delete()
|