|
@@ -5157,14 +5157,13 @@ class Sale extends Base
|
|
|
|
|
|
// if ($sale['sale_status']!=0) throw new \think\Exception($sale['orderCode'] . '已发货,无法取消');
|
|
|
if ($sale['order_type'] == 1) {
|
|
|
- if ($sale['sale_status']!=0) throw new \think\Exception($sale['orderCode'] . '已发货,无法取消');
|
|
|
- $good =Db::name("good")->where(["spuCode"=>$sale['good_code']])->findOrEmpty();
|
|
|
- if(empty($good))throw new Exception('未找到商品信息');
|
|
|
- $stock=Db::name("good")->where($good)->update(["usable_stock"=>$good['usable_stock']+$sale['wsend_num'],"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
- if ($stock == false) throw new Exception('商品库存更新失败');
|
|
|
- } else {
|
|
|
- if (in_array($sale['cgd_status'], [0, 1]) == false) throw new \think\Exception($sale['orderCode'] . '采购单已入库,无法取消');
|
|
|
+ if ($sale['sale_status'] != 0) throw new \think\Exception($sale['orderCode'] . '已发货,无法取消');
|
|
|
+ $good = Db::name("good")->where(["spuCode" => $sale['good_code']])->findOrEmpty();
|
|
|
+ if (empty($good)) throw new Exception('未找到商品信息');
|
|
|
+ $stock = Db::name("good")->where($good)->update(["usable_stock" => $good['usable_stock'] + $sale['wsend_num'], "updatetime" => date("Y-m-d H:i:s")]);
|
|
|
+ if ($stock == false) throw new Exception('商品库存更新失败');
|
|
|
}
|
|
|
+
|
|
|
//修改状态,添加待办
|
|
|
ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
"order_code" => $sale['orderCode'],//销售单号
|
|
@@ -5182,21 +5181,24 @@ class Sale extends Base
|
|
|
'holder_id' => $sale['good_createrid'],
|
|
|
]);
|
|
|
|
|
|
- ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_code" => $sale['cgdNo'],//销售单号
|
|
|
- "status" => $sale['cgd_status'],//这里的status是之前的值
|
|
|
- "action_remark" => '',//备注
|
|
|
- "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
- ], "CGD", 4, ['orderCode' => $sale['cgdNo']]);
|
|
|
+ if ($sale['cgdNo']) {
|
|
|
+ ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_code" => $sale['cgdNo'],//销售单号
|
|
|
+ "status" => $sale['cgd_status'],//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
+ ], "CGD", 4, ['orderCode' => $sale['cgdNo']]);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'CGD',
|
|
|
+ "order_code" => $sale['cgdNo'],
|
|
|
+ "order_id" => $sale['cgd_id'],
|
|
|
+ "order_status" => 4,
|
|
|
+ "before_status" => $sale['cgd_status'],
|
|
|
+ 'holder_id' => $sale['cgder_id'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
|
|
|
- ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
- "order_type" => 'CGD',
|
|
|
- "order_code" => $sale['cgdNo'],
|
|
|
- "order_id" => $sale['cgd_id'],
|
|
|
- "order_status" => 4,
|
|
|
- "before_status" => $sale['cgd_status'],
|
|
|
- 'holder_id' => $sale['cgder_id'],
|
|
|
- ]);
|
|
|
}
|
|
|
Db::name('sale')
|
|
|
->where(['is_del' => 0, 'id' => array_column($list, 'sale_id')])
|
|
@@ -5212,7 +5214,6 @@ class Sale extends Base
|
|
|
->toArray();
|
|
|
if (!empty($out_list)) {
|
|
|
Db::name('order_out')
|
|
|
- ->field('id,outCode,status')
|
|
|
->where(['is_del' => 0, 'orderCode' => $orderCode])
|
|
|
->update(['status' => 5, 'updatetime' => $date]);
|
|
|
foreach ($out_list as $out) {
|
|
@@ -5244,16 +5245,19 @@ class Sale extends Base
|
|
|
->where(['is_del' => 0, 'orderCode' => $orderCode])
|
|
|
->update(['status' => 5, 'updatetime' => $date]);
|
|
|
foreach ($ooc_list as $ooc) {
|
|
|
- $stockinfo =Db::name("good_stock")->where(["spuCode"=>$ooc['spuCode'],"wsm_code"=>$ooc['wsm_code']])->findOrEmpty();
|
|
|
- if(empty($stockinfo))throw new Exception('未找到库存信息');
|
|
|
- $stockup =[
|
|
|
- "usable_stock"=>$stockinfo['usable_stock']+$ooc['num'],
|
|
|
- "wait_out_stock"=>$stockinfo['"wait_out_stock']- $ooc['num'],
|
|
|
- "updatetime" => $date
|
|
|
- ] ;
|
|
|
- $ysup =Db::name("good_stock")->where($stockinfo)->update($stockup);
|
|
|
- if($ysup==false)throw new Exception('库存信息更新失败');
|
|
|
- GoodStockInfo::ChildReturnBn($ooc['outChildCode'],$stockinfo['id'],$ooc['num']);//处理bn数据
|
|
|
+ $stockinfo = Db::name("good_stock")->where(["spuCode" => $ooc['spuCode'], "wsm_code" => $ooc['wsm_code']])->findOrEmpty();
|
|
|
+ if (empty($stockinfo)) throw new Exception('未找到库存信息');
|
|
|
+ $stockup = [
|
|
|
+ "usable_stock" => $stockinfo['usable_stock'] + $ooc['num'],
|
|
|
+ "wait_out_stock" => $stockinfo['wait_out_stock'] - $ooc['num'],
|
|
|
+ "updatetime" => $date
|
|
|
+ ];
|
|
|
+
|
|
|
+ $ysup = Db::name("good_stock")->where($stockinfo)->update($stockup);
|
|
|
+ if ($ysup == false) throw new Exception('库存信息更新失败');
|
|
|
+
|
|
|
+ GoodStockInfo::ChildReturnBn($ooc['outChildCode'], $stockinfo['id'], $ooc['num']);//处理bn数据
|
|
|
+
|
|
|
ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
"order_code" => $ooc['outChildCode'],//销售单号
|
|
|
"status" => $ooc['status'],//这里的status是之前的值
|