|
@@ -188,7 +188,7 @@ class RegimentActive extends Auth{
|
|
|
$productInfo = $Product->getOne($data['product_id']);
|
|
|
if ($productInfo['price'] < $data['regiment_price']) return json_send(['code'=>'error','msg'=>'拼团价格不能大于产品价格']);
|
|
|
// 写入数据表
|
|
|
- $id = $Model->add($data);
|
|
|
+ $id = $Model->edit($id,$data);
|
|
|
// 如果操作失败
|
|
|
if( !$id ) return json_send(['code'=>'error','msg'=>'新增失败']);
|
|
|
//商户开团
|
|
@@ -204,10 +204,14 @@ class RegimentActive extends Auth{
|
|
|
'update_time' => time(),
|
|
|
'insert_time' => time(),
|
|
|
];
|
|
|
- // 开团
|
|
|
- $regimentRes = Regiment::query()->insert($regimentData);
|
|
|
- // 开团结果
|
|
|
- if (!$regimentRes) return json_send(['code'=>'error','msg'=>'商户开团失败']);
|
|
|
+ //查询开团信息
|
|
|
+ $regimentIfo = Regiment::query()->where([['active_id','=',$id]])->first();
|
|
|
+ if (!$regimentIfo){
|
|
|
+ // 开团
|
|
|
+ $regimentRes = Regiment::query()->insert($regimentData);
|
|
|
+ // 开团结果
|
|
|
+ if (!$regimentRes) return json_send(['code'=>'error','msg'=>'商户开团失败']);
|
|
|
+ }
|
|
|
}
|
|
|
// 记录行为
|
|
|
$this->addAdminHistory(admin('uid'),$Model->getTable(),$id,2,$oldData,$data);
|