|
@@ -2,8 +2,13 @@
|
|
|
|
|
|
namespace app\abutment\controller;
|
|
namespace app\abutment\controller;
|
|
|
|
|
|
|
|
+use app\admin\model\ActionLog;
|
|
|
|
+use app\admin\model\GoodLog;
|
|
|
|
+use app\admin\model\ProcessOrder;
|
|
use app\BaseController;
|
|
use app\BaseController;
|
|
|
|
+use think\Exception;
|
|
use think\facade\Db;
|
|
use think\facade\Db;
|
|
|
|
+use think\facade\Validate;
|
|
|
|
|
|
//销售订单(对应于采销端的采购单)
|
|
//销售订单(对应于采销端的采购单)
|
|
class Order extends BaseController
|
|
class Order extends BaseController
|
|
@@ -44,7 +49,9 @@ class Order extends BaseController
|
|
}
|
|
}
|
|
$wsm_in_code = isset($this->post['wsm_in_code']) && $this->post['wsm_in_code'] != "" ? trim($this->post['wsm_in_code']) : "";
|
|
$wsm_in_code = isset($this->post['wsm_in_code']) && $this->post['wsm_in_code'] != "" ? trim($this->post['wsm_in_code']) : "";
|
|
if ($wsm_in_code != "") {
|
|
if ($wsm_in_code != "") {
|
|
- $incode = Db::name("purchease_in")->where(["wsm_in_code" => Db::raw(" like %{$wsm_in_code}%"), "is_del" => 0])->column("cgdNo");
|
|
|
|
|
|
+ $incode = Db::name("purchease_in")
|
|
|
|
+ ->where(["wsm_in_code" => Db::raw(" like %{$wsm_in_code}%"), "is_del" => 0])
|
|
|
|
+ ->column("cgdNo");
|
|
if (empty($incode)) {
|
|
if (empty($incode)) {
|
|
return json_show(1005, "未找到有关入库单信息");
|
|
return json_show(1005, "未找到有关入库单信息");
|
|
}
|
|
}
|
|
@@ -67,11 +74,16 @@ class Order extends BaseController
|
|
}
|
|
}
|
|
$wsm_supplierNo = isset($this->post['wsm_supplierNo']) && $this->post['wsm_supplierNo'] != "" ? trim($this->post['wsm_supplierNo']) : "";
|
|
$wsm_supplierNo = isset($this->post['wsm_supplierNo']) && $this->post['wsm_supplierNo'] != "" ? trim($this->post['wsm_supplierNo']) : "";
|
|
if ($wsm_supplierNo != "") {
|
|
if ($wsm_supplierNo != "") {
|
|
- $supplier = Db::name("supplier")->where(["code" => $wsm_supplierNo])->find();
|
|
|
|
|
|
+ $supplier = Db::name("supplier")
|
|
|
|
+ ->field('id')
|
|
|
|
+ ->where(["code" => $wsm_supplierNo])
|
|
|
|
+ ->find();
|
|
if (empty($supplier)) {
|
|
if (empty($supplier)) {
|
|
return json_show(1004, "未找到供应商信息");
|
|
return json_show(1004, "未找到供应商信息");
|
|
}
|
|
}
|
|
- $wsmcode = Db::name("warehouse_info")->where(["is_del" => 0, "supplierNo" => $wsm_supplierNo])->column("wsm_code");
|
|
|
|
|
|
+ $wsmcode = Db::name("warehouse_info")
|
|
|
|
+ ->where(["is_del" => 0, "supplierNo" => $wsm_supplierNo])
|
|
|
|
+ ->column("wsm_code");
|
|
$where[] = ['po.wsm_code', "in", $wsmcode];
|
|
$where[] = ['po.wsm_code', "in", $wsmcode];
|
|
}
|
|
}
|
|
$start = isset($this->post['start']) && $this->post['start'] != "" ? $this->post['start'] : "";
|
|
$start = isset($this->post['start']) && $this->post['start'] != "" ? $this->post['start'] : "";
|
|
@@ -106,10 +118,14 @@ class Order extends BaseController
|
|
// if(!empty($role['platform']) ){
|
|
// if(!empty($role['platform']) ){
|
|
// $where[]=["po.platform_id","in",$role['platform']];
|
|
// $where[]=["po.platform_id","in",$role['platform']];
|
|
// }
|
|
// }
|
|
- $count = Db::name("purchease_order")->alias('po')->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')->where($where)
|
|
|
|
|
|
+ $count = Db::name("purchease_order")
|
|
|
|
+ ->alias('po')
|
|
|
|
+ ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
|
|
|
|
+ ->where($where)
|
|
->where(function ($query) use ($where) {
|
|
->where(function ($query) use ($where) {
|
|
$query->whereOr([['po.order_type', '<>', 1], ['po.order_source', '=', 0]]);
|
|
$query->whereOr([['po.order_type', '<>', 1], ['po.order_source', '=', 0]]);
|
|
- })->count();
|
|
|
|
|
|
+ })
|
|
|
|
+ ->count('po.id');
|
|
$total = ceil($count / $size);
|
|
$total = ceil($count / $size);
|
|
$page = $page >= $total ? $total : $page;
|
|
$page = $page >= $total ? $total : $page;
|
|
$list = Db::name("purchease_order")
|
|
$list = Db::name("purchease_order")
|
|
@@ -124,12 +140,18 @@ class Order extends BaseController
|
|
->page($page, $size)
|
|
->page($page, $size)
|
|
->order("po.addtime desc")
|
|
->order("po.addtime desc")
|
|
->cursor();
|
|
->cursor();
|
|
|
|
+
|
|
$data = [];
|
|
$data = [];
|
|
foreach ($list as $value) {
|
|
foreach ($list as $value) {
|
|
$value['wsm_name'] = "";
|
|
$value['wsm_name'] = "";
|
|
if ($value['wsm_code'] != "") {
|
|
if ($value['wsm_code'] != "") {
|
|
- $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b", "a.supplierNo=b.code")
|
|
|
|
- ->where(["a.wsm_code" => $value['wsm_code']])->field("a.name as wsm_name,b.name,b.code")->find();
|
|
|
|
|
|
+ $wsmcode = Db::name("warehouse_info")
|
|
|
|
+ ->alias("a")
|
|
|
|
+ ->leftJoin("supplier b", "a.supplierNo=b.code")
|
|
|
|
+ ->where(["a.wsm_code" => $value['wsm_code']])
|
|
|
|
+ ->field("a.name as wsm_name,b.name,b.code")
|
|
|
|
+ ->find();
|
|
|
|
+
|
|
$value['wsm_name'] = isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name'] : "";
|
|
$value['wsm_name'] = isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name'] : "";
|
|
$value['wsm_supplier'] = isset($wsmcode['name']) ? $wsmcode['name'] : "";
|
|
$value['wsm_supplier'] = isset($wsmcode['name']) ? $wsmcode['name'] : "";
|
|
$value['wsm_supplierNo'] = isset($wsmcode['code']) ? $wsmcode['code'] : "";
|
|
$value['wsm_supplierNo'] = isset($wsmcode['code']) ? $wsmcode['code'] : "";
|
|
@@ -330,5 +352,386 @@ class Order extends BaseController
|
|
return json_show(0, "获取成功", $data);
|
|
return json_show(0, "获取成功", $data);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //订单确认
|
|
|
|
+ public function status()
|
|
|
|
+ {
|
|
|
|
+ $this->post = $this->request->filter('trim')->post();
|
|
|
|
+
|
|
|
|
+ $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo'] != "" ? $this->post['cgdNo'] : [];
|
|
|
|
+
|
|
|
|
+ if (empty($cgdNo)) {
|
|
|
|
+ return json_show(1004, "参数cgdNo 不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
|
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
|
|
|
|
+ if ($status === "") {
|
|
|
|
+ return json_show(1004, "参数status 不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($status == 0) {
|
|
|
|
+ $data = Db::name("purchease_order")
|
|
|
|
+ ->field('id,cgdNo')
|
|
|
|
+ ->whereIn('cgdNo', $cgdNo)
|
|
|
|
+ ->where(["is_del" => 0])
|
|
|
|
+ ->where('send_status', '>', 1)
|
|
|
|
+ ->find();
|
|
|
|
+ if (!empty($data)) {
|
|
|
|
+ return json_show(1004, $data['cgdNo'] . "采购单发货中无法取消");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //原始数据
|
|
|
|
+ $info = Db::name("purchease_order")
|
|
|
|
+ ->whereIn('cgdNo', $cgdNo)
|
|
|
|
+ ->column('id,cgdNo,status', 'cgdNo');
|
|
|
|
+
|
|
|
|
+ $upd = Db::name("purchease_order")
|
|
|
|
+ ->whereIn('cgdNo', $cgdNo)
|
|
|
|
+ ->save([
|
|
|
|
+ 'status' => $status,
|
|
|
|
+ 'remark' => $remark,
|
|
|
|
+ 'updatetime' => date("Y-m-d H:i:s"),
|
|
|
|
+ ]);
|
|
|
|
+ if ($upd) {
|
|
|
|
+// $user=GetUserInfo($this->post['token']);
|
|
|
|
+ $uid = $this->request->user['uid']; //isset($user['data']['id'])?$user['data']['id']:0;
|
|
|
|
+ $uname = $this->request->user['nickname'];//isset($user['data']['nickname'])?$user['data']['nickname']:'';
|
|
|
|
+
|
|
|
|
+ foreach ($cgdNo as $vlue) {
|
|
|
|
+ $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0];
|
|
|
|
+ ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], $process);
|
|
|
|
+ $order = ["order_code" => $vlue, "status" => '', "action_remark" => $remark, "action_type" => "status"];
|
|
|
|
+ ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], $order, 'CGD', $status, $this->post);
|
|
|
|
+ }
|
|
|
|
+ return json_show(0, "更新成功");
|
|
|
|
+ } else return json_show(1004, '更新失败');
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //批量入库
|
|
|
|
+ public function add()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $param = $this->request->filter('trim')->post('cgdNo');
|
|
|
|
+
|
|
|
|
+ $val = Validate::rule(['cgdNo|订单编号' => 'require|array|max:100']);
|
|
|
|
+
|
|
|
|
+ //入库方式 供应商包邮,
|
|
|
|
+ //运费 0
|
|
|
|
+
|
|
|
|
+ if (!$val->check($param)) return json_show(1004, $val->getError());
|
|
|
|
+
|
|
|
|
+ $cgdinfo = Db::name("purchease_order")
|
|
|
|
+ ->whereIn('cgdNo', $param['cgdNo'])
|
|
|
|
+ ->where(['is_del' => 0, 'supplierNo' => $this->request->user['supplierNo']])
|
|
|
|
+ ->where('status', '<>', 0)
|
|
|
|
+ ->column('id,wsm_code,good_num', 'cgdNo');
|
|
|
|
+
|
|
|
|
+ if (empty($cgdinfo)) return json_show(1005, "未找到采购单数据或采购单未发货");
|
|
|
|
+
|
|
|
|
+// $wsm_in_code = makeNo("CF");
|
|
|
|
+
|
|
|
|
+ $all_wsm_code = array_column($cgdinfo, 'wsm_code');
|
|
|
|
+
|
|
|
|
+// $wsminfo = Db::name("warehouse_info")
|
|
|
|
+// ->where('is_del',0)
|
|
|
|
+// ->whereIn('wsm_code',$cgdinfo['wsm_code'])
|
|
|
|
+// ->column('','wsm_code');
|
|
|
|
+
|
|
|
|
+// if(empty($wsminfo))return json_show(1004,"未找到仓库信息");
|
|
|
|
+
|
|
|
|
+ $recep = Db::name('warehouse_addr')
|
|
|
|
+ ->where('is_del', 0)
|
|
|
|
+ ->whereIn('wsm_code', $all_wsm_code)
|
|
|
|
+ ->column('wsm_name', 'wsm_code');
|
|
|
|
+
|
|
|
|
+// $sendtype = isset($this->post['sendtype'])&&$this->post['sendtype']!="" ? intval($this->post['sendtype']):"";
|
|
|
|
+// if($sendtype==""){
|
|
|
|
+// return json_show(1004,"参数 sendtype 不能为空");
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// $data = GetUserInfo($this->post['token']);
|
|
|
|
+// if((!empty($data) && $data['code']!=0) ||empty($data) ){
|
|
|
|
+// return json_show($data['code'],$data['message']);
|
|
|
|
+// }
|
|
|
|
+// $userinfo = $data['data'];
|
|
|
|
+// $post_company = isset($this->post['post_company'])&&$this->post['post_company']!="" ? trim($this->post['post_company']):"";
|
|
|
|
+// $post_code = isset($this->post['post_code'])&&$this->post['post_code']!="" ? trim($this->post['post_code']):"";
|
|
|
|
+// $post_fee = isset($this->post['post_fee'])&&$this->post['post_fee']!="" ? $this->post['post_fee']:"0";
|
|
|
|
+// $post_time = isset($this->post['post_time']) && $this->post['post_time'] != "" ? $this->post['post_time'] : date("Y-m-d H:i:s");
|
|
|
|
+// $send_num = isset($this->post['send_num']) && $this->post['send_num'] != "" ? intval($this->post['send_num']) : "";
|
|
|
|
+// $status = isset($this->post['status']) && $this->post['status'] != "" ? intval($this->post['status']) : "1 ";
|
|
|
|
+// if ($send_num == '') {
|
|
|
|
+// return json_show(1004, "参数 send_num 不能为空或零");
|
|
|
|
+// }
|
|
|
|
+// $wsmin_num = Db::name("purchease_in")
|
|
|
|
+// ->where([["cgdNo", "=", $cgdNo], ["is_del", "=", 0], ["status", "not in", [4, 6]]])
|
|
|
|
+// ->sum("send_num");
|
|
|
|
+// if ($send_num > $cgdinfo['wsend_num'] - $wsmin_num) {
|
|
|
|
+// return json_show(1009, "采购单剩余未发货数量不足");
|
|
|
|
+// }
|
|
|
|
+// if($cgdinfo['order_type']==1||$cgdinfo['order_type']==2 ){
|
|
|
|
+// $goodinfo = Db::name("good_basic")->where(["spuCode"=>$cgdinfo['spuCode'],"is_del"=>0])->find();
|
|
|
|
+// if($goodinfo==false){
|
|
|
|
+// return json_show(1004,"商品数据未找到");
|
|
|
|
+// }
|
|
|
|
+// if($goodinfo['is_stock']==0){
|
|
|
|
+// $status=4;
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
|
|
+// $send_way = Db::name("good_zixun")->where(["spuCode" => $cgdinfo['spuCode'], "is_del" => 0])->value('send_way');
|
|
|
|
+// if ($send_way) $status = 4;
|
|
|
|
+// }
|
|
|
|
+// if ($param['sendtype'] == 2 || $cgdinfo['order_type'] != 1) {
|
|
|
|
+// $status = 4;
|
|
|
|
+// }
|
|
|
|
+// $orin = [
|
|
|
|
+// "wsm_in_code" => $wsm_in_code,
|
|
|
|
+// "cgdNo" => $cgdNo,
|
|
|
|
+// "wsm_code" => $cgdinfo['wsm_code'],
|
|
|
|
+// "wsm_reaper" => isset($recep) && $recep['wsm_name'] != '' ? $recep['wsm_name'] : "",
|
|
|
|
+// "send_num" => $send_num,
|
|
|
|
+// "post_company" => $param['post_company'],
|
|
|
|
+// "post_code" => $param['post_code'],
|
|
|
|
+// "post_fee" => $param['post_fee'],
|
|
|
|
+// "sendtime" => $post_time,
|
|
|
|
+// "apply_id" => $this->request->user['uid'],
|
|
|
|
+// "apply_name" => $this->request->user['nickname'],
|
|
|
|
+// "wait_num" => 0,
|
|
|
|
+// "wsm_num" => 0,
|
|
|
|
+// "sendtype" => $param['sendtype'],
|
|
|
|
+// "status" => $status,
|
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
|
+// ];
|
|
|
|
+ Db::startTrans();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ $date = date('Y-m-d H:i:s');
|
|
|
|
+
|
|
|
|
+ $i = 0;
|
|
|
|
+ $status = 0;
|
|
|
|
+ foreach ($param['cgdNo'] as $cgdNo) {
|
|
|
|
+
|
|
|
|
+ if (empty($cgdinfo[$cgdNo])) throw new Exception('未找到采购单数据或采购单未发货');
|
|
|
|
+
|
|
|
|
+ $wsm_in_code = makeNo("CF");
|
|
|
|
+ //改变编码规则,将原编码后两位换成序列号
|
|
|
|
+ //str_pad字符串填充
|
|
|
|
+ $wsm_in_code = substr($wsm_in_code, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
|
+ $i++;
|
|
|
|
+
|
|
|
|
+ $win = Db::name("purchease_in")->insertGetId([
|
|
|
|
+ "wsm_in_code" => $wsm_in_code,
|
|
|
|
+ "cgdNo" => $cgdNo,
|
|
|
|
+ "wsm_code" => $cgdinfo[$cgdNo]['wsm_code'],
|
|
|
|
+ "wsm_reaper" => isset($recep[$cgdinfo[$cgdNo]['wsm_code']]) ? $recep[$cgdinfo[$cgdNo]['wsm_code']] : '',
|
|
|
|
+ "send_num" => $cgdinfo[$cgdNo]['good_num'],
|
|
|
|
+ "post_company" => '',
|
|
|
|
+ "post_code" => '',
|
|
|
|
+ "post_fee" => 0,//运费固定值:0
|
|
|
|
+ "sendtime" => $date,
|
|
|
|
+ "apply_id" => $this->request->user['uid'],
|
|
|
|
+ "apply_name" => $this->request->user['nickname'],
|
|
|
|
+ "wait_num" => 0,
|
|
|
|
+ "wsm_num" => 0,
|
|
|
|
+ "sendtype" => 2,//发货方式,固定值,供应商包邮2
|
|
|
|
+ "status" => $status,
|
|
|
|
+ "addtime" => $date,
|
|
|
|
+ "updatetime" => $date
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ if ($win) {
|
|
|
|
+ $sto = ["order_code" => $wsm_in_code, "status" => $status, "action_remark" => '', "action_type" => "edit"];
|
|
|
|
+ ActionLog::logAdd(['id' => $this->request->user['uid'], 'nickname' => $this->request->user['nickname']], $sto, "RKD", $status, $this->post);
|
|
|
|
+ $process = ["order_code" => $wsm_in_code, "order_id" => $win, "order_status" => $status, "order_type" => 'RKD', "before_status" => $status];
|
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->request->user['uid'], 'nickname' => $this->request->user['nickname']], $process);
|
|
|
|
+// $order = ["order_code" => $cgdNo, "status" => $cgdinfo['status'], "action_remark" => '', "action_type" => "edit"];
|
|
|
|
+
|
|
|
|
+ //维护台账信息
|
|
|
|
+ Db::execute("UPDATE `wsm_standing_book` SET `wsm_in_code`=CONCAT(IFNULL(`wsm_in_code`,''),',{$wsm_in_code}'),`updatetime`='" . $date . "' WHERE `cgdNo`='{$cgdNo}'");
|
|
|
|
+
|
|
|
|
+ } else throw new Exception('新建入库单失败');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Db::commit();
|
|
|
|
+ return json_show(0, '新建入库单成功', ["wsm_in_code" => $wsm_in_code]);
|
|
|
|
+
|
|
|
|
+// $win = Db::name("purchease_in")->insert($orin, true);
|
|
|
|
+// if ($win) {
|
|
|
|
+// $sto = ["order_code" => $wsm_in_code, "status" => $status, "action_remark" => '', "action_type" => "edit"];
|
|
|
|
+// ActionLog::logAdd($this->post['token'], $sto, "RKD", $status, $this->post);
|
|
|
|
+// $process = ["order_code" => $wsm_in_code, "order_id" => $win, "order_status" => $status, "order_type" => 'RKD', "before_status" => $status];
|
|
|
|
+// ProcessOrder::AddProcess($this->post['token'], $process);
|
|
|
|
+// $order = ["order_code" => $cgdNo, "status" => $cgdinfo['status'], "action_remark" => '', "action_type" => "edit"];
|
|
|
|
+
|
|
|
|
+ //维护台账信息
|
|
|
|
+// Db::execute("UPDATE `wsm_standing_book` SET `wsm_in_code`=CONCAT(IFNULL(`wsm_in_code`,''),',{$wsm_in_code}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE `cgdNo`='{$cgdNo}'");
|
|
|
|
+
|
|
|
|
+// if ($status == 1) {
|
|
|
|
+// Db::commit();
|
|
|
|
+// return json_show(0, '新建成功', ["wsm_in_code" => $wsm_in_code]);
|
|
|
|
+// }
|
|
|
|
+// if ($status == 4) {
|
|
|
|
+// $cgdinfo['wsend_num'] -= $send_num;
|
|
|
|
+// $cgdinfo['send_num'] += $send_num;
|
|
|
|
+// $cgdinfo['send_status'] = $cgdinfo['wsend_num'] == 0 ? 3 : ($cgdinfo['send_num'] == 0 ? 1 : 2);
|
|
|
|
+// $cgdinfo['status'] = $cgdinfo['wsend_num'] == 0 ? 3 : ($cgdinfo['send_num'] == 0 ? 1 : 2);
|
|
|
|
+// $cgdinfo['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+// $up = Db::name("purchease_order")->save($cgdinfo);
|
|
|
|
+// if ($up == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "新建失败");
|
|
|
|
+// }
|
|
|
|
+// $good = Db::name("good_stock")->where(["wsm_code" => $cgdinfo['wsm_code'], "spuCode" => $cgdinfo['spuCode'], "is_del" => 0])->lock(true)->find();
|
|
|
|
+// if (empty($good)) {
|
|
|
|
+// $good = [
|
|
|
|
+// "spuCode" => $cgdinfo['spuCode'],
|
|
|
|
+// "wsm_code" => $cgdinfo['wsm_code'],
|
|
|
|
+// "usable_stock" => 0,
|
|
|
|
+// "wait_out_stock" => 0,
|
|
|
|
+// "wait_in_stock" => $send_num,
|
|
|
|
+// "total_stock" => 0,
|
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
|
+// "updatetime" => date("Y-m-d H:i:s"),
|
|
|
|
+// ];
|
|
|
|
+// // $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
|
|
|
|
+// // "action_type"=>"create"];
|
|
|
|
+// } else {
|
|
|
|
+// // $order = ["order_code"=>$good['spuCode'],"status"=>1,"action_remark"=>'',
|
|
|
|
+// // "action_type"=>"edit"];
|
|
|
|
+// }
|
|
|
|
+// $good['wait_in_stock'] -= $send_num;
|
|
|
|
+//// if($good['presale_stock']>0){
|
|
|
|
+//// if($good['presale_stock']>=$send_num){
|
|
|
|
+//// $good['presale_stock']-=$send_num;
|
|
|
|
+//// $good['wait_out_stock']+=$send_num;
|
|
|
|
+//// }else{
|
|
|
|
+//// $good['presale_stock']=0;
|
|
|
|
+//// $good['usable_stock']+=$send_num-$good['presale_stock'];
|
|
|
|
+//// $good['wait_out_stock']+=$good['presale_stock'];
|
|
|
|
+//// }
|
|
|
|
+//// }else{
|
|
|
|
+// $good['usable_stock'] += $send_num;
|
|
|
|
+// // }
|
|
|
|
+//
|
|
|
|
+// $good['total_stock'] = $good['usable_stock'] + $good['wait_out_stock'];
|
|
|
|
+// $good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+// $upd = Db::name("good_stock")->save($good);
|
|
|
|
+// //商品变动日志表,good_log_code字段存储采购单单号
|
|
|
|
+// $good_data[] = ['good_log_code' => $wsm_in_code, "stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1, 'stock' => $send_num, "stock_name" => "usable_stock"];
|
|
|
|
+// $good_data[] = ['good_log_code' => $wsm_in_code, "stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 2, 'stock' => $send_num, "stock_name" => "wait_in_stock"];
|
|
|
|
+// if ($upd) {
|
|
|
|
+// GoodLog::LogAdd($this->post['token'], $good_data, 'RKD');
|
|
|
|
+// if ($cgdinfo['order_type'] == 1) {
|
|
|
|
+// $bk = Db::name("order_bk")->where(['cgdNo' => $cgdinfo['cgdNo']])->find();
|
|
|
|
+// if ($bk == false) {
|
|
|
|
+// $bk = [
|
|
|
|
+// "cgdNo" => $cgdinfo['cgdNo'],
|
|
|
|
+// "spuCode" => $cgdinfo['spuCode'],
|
|
|
|
+// "companyNo" => $cgdinfo['companyNo'],
|
|
|
|
+// "total_num" => $send_num,
|
|
|
|
+// "merge_num" => 0,
|
|
|
|
+// "balance_num" => $send_num,
|
|
|
|
+// "status" => 1,
|
|
|
|
+// "is_del" => 0,
|
|
|
|
+// 'addtime' => date("Y-m-d H:i:s"),
|
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
|
+// ];
|
|
|
|
+// $upcgd = Db::name("order_bk")->save($bk);
|
|
|
|
+// } else {
|
|
|
|
+// $where = ['id' => $bk['id'], 'total_num' => $bk['total_num'], 'balance_num' => $bk['balance_num']];
|
|
|
|
+// $bk['balance_num'] += $send_num;
|
|
|
|
+// $bk['total_num'] += $send_num;
|
|
|
|
+// $bk['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+// $upcgd = Db::name("order_bk")->where($where)->update($bk);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if ($upcgd == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "采购单数量更新失败");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if ($cgdinfo['send_status'] == 3 && $cgdinfo['order_type'] != 1) {
|
|
|
|
+// $send = Db::name("order_send")->where(["cgdNo" => $cgdNo, "status" => 1])->column("outCode");
|
|
|
|
+// if (!empty($send)) {
|
|
|
|
+// $out = Db::name("order_out")->where(["outCode" => $send, "status" => 0])->select()
|
|
|
|
+// ->toArray();
|
|
|
|
+// if (!empty($out)) {
|
|
|
|
+// $up = Db::name("order_out")->where(["outCode" => $send, "status" => 0])->update
|
|
|
|
+// (["status" => 1, 'wsm_code' => $cgdinfo['wsm_code'], "updatetime" => date('Y-m-d H:i:s')]);
|
|
|
|
+// if ($up == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "出库单出库失败");
|
|
|
|
+// } else {
|
|
|
|
+// foreach ($out as $k => $v_outCode) {
|
|
|
|
+// //修改状态,添加待办
|
|
|
|
+// ActionLog::logAdd($this->post['token'], [
|
|
|
|
+// "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
|
+// "status" => 0,//这里的status是之前的值
|
|
|
|
+// "action_remark" => '',//备注
|
|
|
|
+// "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
|
+// ], "CKD", 1, $this->post);
|
|
|
|
+//
|
|
|
|
+// ProcessOrder::AddProcess($this->post['token'], [
|
|
|
|
+// "order_type" => 'CKD',
|
|
|
|
+// "order_code" => $v_outCode['outCode'],//出库单号
|
|
|
|
+// "order_id" => $v_outCode['id'],
|
|
|
|
+// "order_status" => 1, "before_status" => 0
|
|
|
|
+// ]);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// $good1 = Db::name("good_stock")->where(["wsm_code" => $cgdinfo['wsm_code'], "spuCode" => $cgdinfo['spuCode'], "is_del" => 0])->find();
|
|
|
|
+// if ($good1 == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "未找到对应商品库存");
|
|
|
|
+// }
|
|
|
|
+// $out_num = intval(array_sum(array_column($out, "send_num")));
|
|
|
|
+// if ($out_num > $good1['usable_stock']) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "库存数量不足发货");
|
|
|
|
+// }
|
|
|
|
+// $good1['usable_stock'] -= $out_num;
|
|
|
|
+// $good1['wait_out_stock'] += $out_num;
|
|
|
|
+// $good1['total_stock'] = $good1['usable_stock'] + $good1['wait_out_stock'];
|
|
|
|
+// $good1['updatetime'] = date("Y-m-d H:i:s");
|
|
|
|
+// $upd = Db::name("good_stock")->save($good1);
|
|
|
|
+// if ($upd == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "库存数量更新失败");
|
|
|
|
+// }
|
|
|
|
+// $good_data[] = ['good_log_code' => $wsm_in_code, "stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1, 'stock' => $send_num, "stock_name" => "wait_out_stock"];
|
|
|
|
+// $good_data[] = ['good_log_code' => $wsm_in_code, "stock_id" => isset($good['id']) ? $good['id'] : Db::name("good_stock")->getLastInsID(), "type" => 1, 'stock' => $send_num, "stock_name" => "usable_stock"];
|
|
|
|
+// GoodLog::LogAdd($this->post['token'], $good_data, 'RKD');
|
|
|
|
+// $sendp = Db::name("order_send")->where(["cgdNo" => $cgdNo, "outCode" => $send, "status" => 1])->save(["status" => 2]);
|
|
|
|
+// if ($sendp == false) {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "库存发货失败");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// ActionLog::logAdd($this->post['token'], $order, "CGD", $cgdinfo['status'], $cgdinfo);
|
|
|
|
+// $process = ["order_code" => $cgdNo, "order_id" => $cgdinfo['id'], "order_status" => $cgdinfo['status'], "order_type" => 'CGD', "before_status" => $order['status']];
|
|
|
|
+// ProcessOrder::AddProcess($this->post['token'], $process);
|
|
|
|
+// Db::commit();
|
|
|
|
+// return json_show(0, '商品入库成功', ["wsm_in_code" => $wsm_in_code]);
|
|
|
|
+// } else {
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1002, "商品入库失败");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// Db::commit();
|
|
|
|
+// return json_show(0, '新建成功', ["wsm_in_code" => $wsm_in_code]);
|
|
|
|
+// }
|
|
|
|
+// Db::rollback();
|
|
|
|
+// return json_show(1004, "新建失败");
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
+ Db::rollback();
|
|
|
|
+ return json_show(1004, $e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|