|
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
//销售单退货工单
|
|
|
use app\admin\model\ActionLog;
|
|
|
+use app\admin\model\DataGroup as DataGroupModel;
|
|
|
use app\admin\model\ProcessOrder;
|
|
|
use think\Exception;
|
|
|
use think\facade\Db;
|
|
@@ -117,29 +118,50 @@ class ReorderChild extends Base
|
|
|
public function getList()
|
|
|
{
|
|
|
|
|
|
- $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => '', 'orderCode' => '', 'outCode' => '', 'outChildCode' => '', 'saleReturnChildCode' => '', 'order_type' => ''], 'post', 'trim');
|
|
|
-
|
|
|
- $where = [['a.is_del', '=', 0]];
|
|
|
- if ($param['returnCode'] != '') $where[] = ['a.returnCode', 'like', '%' . $param['returnCode'] . '%'];
|
|
|
- if ($param['status'] !== '') $where[] = ['a.status', '=', $param['status']];
|
|
|
- if ($param['orderCode'] != '') $where[] = ['a.orderCode', 'like', '%' . $param['orderCode'] . '%'];
|
|
|
- if ($param['outCode'] != '') $where[] = ['a.outCode', 'like', '%' . $param['outCode'] . '%'];
|
|
|
- if ($param['outChildCode'] != '') $where[] = ['a.outChildCode', 'like', '%' . $param['outChildCode'] . '%'];
|
|
|
- if ($param['saleReturnChildCode'] != '') $where[] = ['a.saleReturnChildCode', 'like', '%' . $param['saleReturnChildCode'] . '%'];
|
|
|
- if ($param['order_type'] !== '') $where[] = ['b.order_type', '=', $param['order_type']];
|
|
|
-
|
|
|
- $count = Db::name('sale_return_child')
|
|
|
- ->alias('a')
|
|
|
- ->leftJoin('sale_return b', 'b.returnCode=a.returnCode and b.is_del=0')
|
|
|
- ->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code and c.is_del=0')->where($where)
|
|
|
- ->count('a.id');
|
|
|
-
|
|
|
- $list = Db::name('sale_return_child')
|
|
|
+ $db = Db::name('sale_return_child')
|
|
|
->alias('a')
|
|
|
- ->field('a.id,a.saleReturnChildCode,a.type,a.outChildCode,a.outCode,a.companyNo,a.companyName,a.customer_code,a.customerName,a.num,a.sale_price,a.total_price,a.status,a.addtime,b.supplierNo,b.supplierName,a.return_wsm_code,c.name return_wsm_name,c.supplierNo return_supplierNo,c.supplierName return_supplierName,c.contactor_name return_contactor_name,b.order_type')
|
|
|
->leftJoin('sale_return b', 'b.returnCode=a.returnCode and b.is_del=0')
|
|
|
->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code and c.is_del=0')
|
|
|
- ->where($where)
|
|
|
+ ->where('a.is_del', 0);
|
|
|
+
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'returnCode' => '', 'status' => '', 'orderCode' => '', 'outCode' => '', 'outChildCode' => '', 'saleReturnChildCode' => '', 'order_type' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+
|
|
|
+ if ($param['returnCode'] != '') $db->whereLike('a.returnCode', '%' . $param['returnCode'] . '%');
|
|
|
+ if ($param['status'] !== '') $db->where('a.status', $param['status']);
|
|
|
+ if ($param['orderCode'] != '') $db->whereLike('a.orderCode', '%' . $param['orderCode'] . '%');
|
|
|
+ if ($param['outCode'] != '') $db->whereLike('a.outCode', '%' . $param['outCode'] . '%');
|
|
|
+ if ($param['outChildCode'] != '') $db->whereLike('a.outChildCode', '%' . $param['outChildCode'] . '%');
|
|
|
+ if ($param['saleReturnChildCode'] != '') $db->whereLike('a.saleReturnChildCode', '%' . $param['saleReturnChildCode'] . '%');
|
|
|
+ if ($param['order_type'] !== '') $db->where('b.order_type', $param['order_type']);
|
|
|
+ if ($param['supplierNo'] != '') $db->whereLike('b.supplierNo', '%' . $param['supplierNo'] . '%');
|
|
|
+
|
|
|
+ //供应商账号,只查询该供应商下所有数据
|
|
|
+ if ($this->level == 3 && $param['supplierNo'] == '') return json_show(1004, '供应商账号时供应商编码不能为空');
|
|
|
+
|
|
|
+ //1.超管,查看全部;
|
|
|
+ //2.业务公司账号-申请人,初始状态只查看自己创建的;
|
|
|
+ //3.业务公司账号-退回仓库负责人,只查看自己负责仓库的数据;
|
|
|
+ //4.业务公司账号-数据共享接受人,共享给自己的数据;
|
|
|
+ if ($this->level == 2) {
|
|
|
+
|
|
|
+ //是否仓库负责人
|
|
|
+ $is_contactor = Db::name('warehouse_info')
|
|
|
+ ->field('id')
|
|
|
+ ->where(['is_del' => 0, 'contactor' => $this->uid])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if (empty($is_contactor)) {
|
|
|
+ $role = $this->checkDataShare();
|
|
|
+ $hand = resign_hand_user($this->uid, 0);
|
|
|
+ $db->whereIn('b.apply_id', array_unique(array_merge($role[DataGroupModel::$type_全部], $hand)));
|
|
|
+ } else {
|
|
|
+ $db->where('`a`.`return_wsm_code` in ' . Db::name('warehouse_info')->field('wsm_code')->where(['is_del' => 0, 'contactor' => $this->uid])->buildSql());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $count = $db->count('a.id');
|
|
|
+
|
|
|
+ $list = $db
|
|
|
+ ->field('a.id,a.saleReturnChildCode,a.type,a.outChildCode,a.outCode,a.companyNo,a.companyName,a.customer_code,a.customerName,a.num,a.sale_price,a.total_price,a.status,a.addtime,b.supplierNo,b.supplierName,a.return_wsm_code,c.name return_wsm_name,c.supplierNo return_supplierNo,c.supplierName return_supplierName,c.contactor_name return_contactor_name,b.order_type,a.orderCode,a.returnCode,b.apply_name,b.apply_id')
|
|
|
->order(['a.addtime' => 'desc', 'a.id' => 'desc'])
|
|
|
->page($param['page'], $param['size'])
|
|
|
->select()
|
|
@@ -339,7 +361,7 @@ class ReorderChild extends Base
|
|
|
|
|
|
$info = Db::name('sale_return_child')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,b.supplierNo,b.supplierName,c.name return_wsm_name,c.supplierNo return_supplierNo,c.supplierName return_supplierName,c.contactor_name return_contactor_name')
|
|
|
+ ->field('a.*,b.supplierNo,b.supplierName,c.name return_wsm_name,c.supplierNo return_supplierNo,c.supplierName return_supplierName,c.contactor_name return_contactor_name,b.good_code spuCode,b.order_type')
|
|
|
->leftJoin('sale_return b', 'b.returnCode=a.returnCode and b.is_del=0')
|
|
|
->leftJoin('warehouse_info c', 'c.wsm_code=a.return_wsm_code and c.is_del=0')
|
|
|
->where(['a.is_del' => 0, 'a.id' => $param['id']])
|