|
@@ -1091,22 +1091,62 @@ class Goodup extends Base
|
|
|
return app_show(0,"获取成功",$data);
|
|
|
}
|
|
|
|
|
|
- public function delall(){
|
|
|
- $supcode = isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
|
|
|
- if($supcode==""){
|
|
|
- return error_show(1004,"参数codes不能为空");
|
|
|
- }
|
|
|
- $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
- if(empty($data)){
|
|
|
- return error_show(1004,"未找到商品数据");
|
|
|
+ //删除商品成本
|
|
|
+ public function delall()
|
|
|
+ {
|
|
|
+// $supcode = isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
|
|
|
+ $supcode = $this->request->post('codes', '', 'trim');
|
|
|
+ if ($supcode == "") {
|
|
|
+ return error_show(1004, "参数codes不能为空");
|
|
|
}
|
|
|
- $up= Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save(["is_del"=>1]);
|
|
|
- if($up){
|
|
|
- ProcessOrder::workdel(["order_type"=>"CGD","order_code"=>$supcode]);
|
|
|
- return app_show(0,"更新成功");
|
|
|
- }else{
|
|
|
- return error_show(1005,"更新失败");
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $good_basic = Db::name("good_basic")
|
|
|
+ ->field('id,spuCode,status')
|
|
|
+ ->where(["spuCode" => $supcode, "is_del" => 0])
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if (empty($good_basic)) throw new Exception('该记录不存在或已删除');
|
|
|
+
|
|
|
+ $good = Db::name('good')
|
|
|
+ ->field('id,status')
|
|
|
+ ->where(['spuCode' => $supcode, 'is_del' => 0])
|
|
|
+ ->whereIn('status', [1, 8])
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if (empty($good)) throw new Exception('该上线商品记录不存在或不允许删除,请检查商品是否下线');
|
|
|
+
|
|
|
+ Db::name("good_basic")
|
|
|
+ ->where(['id' => $good_basic['id'], 'is_del' => 0])
|
|
|
+ ->update(['is_del' => 1, 'updatetime' => date('Y-m-d H:i:s')]);
|
|
|
+
|
|
|
+ Db::name("good")
|
|
|
+ ->where(['id' => $good['id'], 'is_del' => 0])
|
|
|
+ ->update(['is_del' => 1, 'updatetime' => date('Y-m-d H:i:s')]);
|
|
|
+
|
|
|
+ ProcessOrder::workdel(["order_type" => "CGD", "order_code" => $supcode]);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ app_show(0, "删除成功");
|
|
|
+ } catch (Exception $exception) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005, "删除失败");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
|
|
|
+// if(empty($data)){
|
|
|
+// return error_show(1004,"未找到商品数据");
|
|
|
+// }
|
|
|
+// $up= Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save(["is_del"=>1]);
|
|
|
+// if($up){
|
|
|
+// ProcessOrder::workdel(["order_type"=>"CGD","order_code"=>$supcode]);
|
|
|
+// return app_show(0,"更新成功");
|
|
|
+// }else{
|
|
|
+// return error_show(1005,"更新失败");
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
//添加上线商品
|