|
@@ -3,8 +3,10 @@
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
//发货工单(从属于发货单)
|
|
|
+use app\admin\model\ActionLog;
|
|
|
use app\admin\model\DataGroup as DataGroupModel;
|
|
|
use app\admin\model\GoodStockInfo;
|
|
|
+use app\admin\model\ProcessOrder;
|
|
|
use think\Exception;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Validate;
|
|
@@ -166,6 +168,7 @@ class OrderOutChild extends Base
|
|
|
'apply_id' => '',
|
|
|
'apply_name' => '',
|
|
|
'order_type' => '',
|
|
|
+ 'relaComNo' => '',
|
|
|
], 'post', 'trim');
|
|
|
|
|
|
$where = [['a.is_del', '=', 0]];
|
|
@@ -185,12 +188,42 @@ class OrderOutChild extends Base
|
|
|
if ($param['apply_id'] !== '') $where[] = ['a.apply_id', '=', $param['apply_id']];
|
|
|
if ($param['apply_name'] != '') $where[] = ['a.apply_name', 'like', '%' . $param['apply_name'] . '%'];
|
|
|
if ($param['order_type'] != '') $where[] = ['a.order_type', '=', $param['order_type']];
|
|
|
+ if ($param['relaComNo'] != '') $where[] = ['a.companyNo', '=', $param['relaComNo']];
|
|
|
+
|
|
|
+ $condition = '';
|
|
|
+ //只有level2的账号过滤数据权限
|
|
|
+ if ($this->level == 2) {
|
|
|
+
|
|
|
+ //库管只能看到库存品订单,供应商负责人只能看到非库存品订单
|
|
|
+
|
|
|
+ //是否是仓库管理员
|
|
|
+ $tmp = Db::name('warehouse_info')->field('id')->where(['is_del' => 0, 'contactor' => $this->uid])->findOrEmpty();
|
|
|
+
|
|
|
+ //库管看到所有的库存品发货申请单
|
|
|
+ if (!empty($tmp)) $condition .= " a.order_type=1 AND c.contactor=" . $this->uid;
|
|
|
+ else {
|
|
|
+ $role = $this->checkDataShare();
|
|
|
+ if (!empty($role[DataGroupModel::$type_全部])) {
|
|
|
+ if ($condition != '') $condition .= " or ";
|
|
|
+ $condition .= " a.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $person_supplier = Db::connect('mysql_sys')
|
|
|
+ ->name('supplier')
|
|
|
+ ->where(['is_del' => 0, 'personid' => $this->uid])
|
|
|
+ ->column('code');
|
|
|
+ if ($person_supplier) {
|
|
|
+ if ($condition != '') $condition .= " or ";
|
|
|
+ $condition .= "(a.order_type<>1 and a.supplierNo in ('" . implode('\',\'', $person_supplier) . "'))";
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$list = Db::name('order_out_child')
|
|
|
->alias('a')
|
|
|
->field('a.outChildCode 发货工单号,a.orderCode 确认单编号,a.outCode 发货申请单号,a.companyNo 业务公司编号,a.companyName 业务公司名称,a.customer_code 客户编号,a.customer_name 客户名称,a.supplierNo 供应商编号,a.supplierName 供应商名称,a.spuCode 商品成本编号,a.skuCode 商品上线编号,a.good_name 商品名称,case a.order_source when 1 then "直接下单" when 2 then "咨询" when 3 then "项目" when 4 then "平台" when 5 then "有赞" when 6 then "售后补换货" when 7 then "报备转单" when 8 then "支付渠道" end "订单来源",case order_type when 1 then "备库" when 2 then "非库存" when 3 then "咨询商品" when 4 then "报备商品" end "商品类型",a.num 数量,case a.status when 1 then "待发货" when 2 then "发货完成" when 3 then "已收货" when 4 then "已全部退货" end "分单状态",a.addtime 下单时间,a.apply_name 申请人名称,a.post_name 物流公司,a.post_code 物流单号,a.post_fee 物流费用')
|
|
|
->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
|
|
|
->where($where)
|
|
|
+ ->where($condition)
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
@@ -349,7 +382,7 @@ class OrderOutChild extends Base
|
|
|
|
|
|
$child = Db::name('order_out_child')
|
|
|
->where(['is_del' => 0, 'status' => 1, 'outChildCode' => array_column($param, 'outChildCode')])
|
|
|
- ->column('id,orderCode,outCode,num,wsm_code,supplierNo', 'outChildCode');
|
|
|
+ ->column('id,orderCode,outCode,num,wsm_code,supplierNo,apply_id', 'outChildCode');
|
|
|
|
|
|
//检查所有的发货单是否有正在进行的售后单
|
|
|
$temp = Db::name('order_return')
|
|
@@ -361,11 +394,11 @@ class OrderOutChild extends Base
|
|
|
|
|
|
$order_out = Db::name('order_out')
|
|
|
->where(['is_del' => 0, 'outCode' => array_unique(array_column($child, 'outCode'))])
|
|
|
- ->column('id,send_num,send_status,0 already_send_num', 'outCode');
|
|
|
+ ->column('id,send_num,send_status,0 already_send_num,status,apply_id', 'outCode');
|
|
|
|
|
|
$sale = Db::name('sale')
|
|
|
->where(['is_del' => 0, 'orderCode' => array_unique(array_column($child, 'orderCode'))])
|
|
|
- ->column('id,good_num,send_num,wsend_num,good_code,supNo,is_stock,order_source', 'orderCode');
|
|
|
+ ->column('id,good_num,send_num,wsend_num,good_code,supNo,is_stock,order_source,cgderid,status', 'orderCode');
|
|
|
|
|
|
$is_reurn = Db::name("sale_return")
|
|
|
->field('id,orderCode')
|
|
@@ -435,6 +468,28 @@ class OrderOutChild extends Base
|
|
|
'updatetime' => $date,
|
|
|
]);
|
|
|
|
|
|
+ //修改状态,添加待办
|
|
|
+ ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_code" => $value['outChildCode'],//单号
|
|
|
+ "status" => 1,//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
+ ], "FHGD", 2, ['post_name' => $value['post_name'],
|
|
|
+ 'post_code' => $value['post_code'],
|
|
|
+ 'post_fee' => $value['post_fee'],
|
|
|
+ 'status' => 2,
|
|
|
+ 'sendtime' => $date,
|
|
|
+ 'updatetime' => $date]);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'FHGD',
|
|
|
+ "order_code" => $value['outChildCode'],//单号
|
|
|
+ "order_id" => $child[$value['outChildCode']]['id'],
|
|
|
+ "order_status" => 2,
|
|
|
+ "before_status" => 1,
|
|
|
+ 'holder_id' => $child[$value['outChildCode']]['apply_id']
|
|
|
+ ]);
|
|
|
+
|
|
|
$order_out[$child[$value['outChildCode']]['outCode']]['already_send_num'] += $child[$value['outChildCode']]['num'];
|
|
|
|
|
|
//发货单
|
|
@@ -446,15 +501,41 @@ class OrderOutChild extends Base
|
|
|
$sale[$child[$value['outChildCode']]['orderCode']]['send_num'] += $child[$value['outChildCode']]['num'];
|
|
|
$sale[$child[$value['outChildCode']]['orderCode']]['wsend_num'] -= $child[$value['outChildCode']]['num'];
|
|
|
|
|
|
+ //修改状态,添加待办
|
|
|
+ ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_code" => $child[$value['outChildCode']]['outCode'],//单号
|
|
|
+ "status" => $order_out[$child[$value['outChildCode']]['outCode']]['status'],//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
+ ], "CKD", 2, ['send_status' => $order_out[$child[$value['outChildCode']]['outCode']]['already_send_num'] >= $order_out[$child[$value['outChildCode']]['outCode']]['send_num'] ? 4 : 3, 'status' => 2, 'updatetime' => $date]);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'CKD',
|
|
|
+ "order_code" => $child[$value['outChildCode']]['outCode'],//单号
|
|
|
+ "order_id" => $order_out[$child[$value['outChildCode']]['outCode']]['id'],
|
|
|
+ "order_status" => 2,
|
|
|
+ "before_status" => $order_out[$child[$value['outChildCode']]['outCode']]['status'],
|
|
|
+ 'holder_id' => $order_out[$child[$value['outChildCode']]['outCode']]['apply_id']
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
//销售单
|
|
|
$send_status = $sale[$child[$value['outChildCode']]['orderCode']]['send_num'] >= $sale[$child[$value['outChildCode']]['orderCode']]['good_num'] ? 4 : 3;
|
|
|
+
|
|
|
+ $sale_update_data = [
|
|
|
+ 'send_num' => $sale[$child[$value['outChildCode']]['orderCode']]['send_num'],
|
|
|
+ 'wsend_num' => $sale[$child[$value['outChildCode']]['orderCode']]['wsend_num'],
|
|
|
+ 'send_status' => $send_status,
|
|
|
+ 'updatetime' => $date
|
|
|
+ ];
|
|
|
+
|
|
|
+ if ($sale_update_data['wsend_num'] == 0) $sale_update_data['status'] = 2;
|
|
|
+ elseif ($sale_update_data['send_num'] == 0) $sale_update_data['status'] = 0;
|
|
|
+ else $sale_update_data['status'] = 1;
|
|
|
+
|
|
|
Db::name('sale')
|
|
|
->where(['is_del' => 0, 'id' => $sale[$child[$value['outChildCode']]['orderCode']]['id']])
|
|
|
- ->update([
|
|
|
- 'send_num' => $sale[$child[$value['outChildCode']]['orderCode']]['send_num'],
|
|
|
- 'wsend_num' => $sale[$child[$value['outChildCode']]['orderCode']]['wsend_num'],
|
|
|
- 'send_status' => $send_status,
|
|
|
- ]);
|
|
|
+ ->update($sale_update_data);
|
|
|
|
|
|
if ($sale[$child[$value['outChildCode']]['orderCode']]['order_source'] == 5 && $send_status == 4) {
|
|
|
$yz_tmp[] = [
|
|
@@ -465,6 +546,23 @@ class OrderOutChild extends Base
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ //修改状态,添加待办
|
|
|
+ ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_code" => $child[$value['outChildCode']]['orderCode'],//单号
|
|
|
+ "status" => $sale[$child[$value['outChildCode']]['orderCode']]['status'],//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "status"//新建create,编辑edit,更改状态status
|
|
|
+ ], "XSQRD", $sale_update_data['status'], $sale_update_data);
|
|
|
+
|
|
|
+ ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
+ "order_type" => 'XSQRD',
|
|
|
+ "order_code" => $child[$value['outChildCode']]['orderCode'],//单号
|
|
|
+ "order_id" => $sale[$child[$value['outChildCode']]['orderCode']]['id'],
|
|
|
+ "order_status" => $sale_update_data['status'],
|
|
|
+ "before_status" => $sale[$child[$value['outChildCode']]['orderCode']]['status'],
|
|
|
+ 'holder_id' => $sale[$child[$value['outChildCode']]['orderCode']]['cgderid']
|
|
|
+ ]);
|
|
|
+
|
|
|
//库存
|
|
|
Db::name('good_stock')
|
|
|
->where(['is_del' => 0, 'spuCode' => $sale[$child[$value['outChildCode']]['orderCode']]['good_code'], 'wsm_code' => $child[$value['outChildCode']]['wsm_code']])
|