|
@@ -4,6 +4,7 @@ namespace app\admin\controller;
|
|
|
|
|
|
use app\abutment\model\SupplierRelationUser;
|
|
|
use app\abutment\model\SupplierUser;
|
|
|
+use app\admin\model\DataGroup as DataGroupModel;
|
|
|
use app\admin\model\GoodLog;
|
|
|
use app\admin\model\ProcessOrder;
|
|
|
use Exception;
|
|
@@ -2066,16 +2067,24 @@ class Sale extends Base
|
|
|
$end .= " 23:59:59";
|
|
|
$where[] = ["s.addtime", '<=', $end];
|
|
|
}
|
|
|
- $role = $this->checkRole();
|
|
|
- if (!empty($role['write'])) {
|
|
|
- $where[] = ["s.apply_id", "in", $role['write']];
|
|
|
- }
|
|
|
+// $role = $this->checkRole();
|
|
|
+// if (!empty($role['write'])) {
|
|
|
+// $where[] = ["s.apply_id", "in", $role['write']];
|
|
|
+// }
|
|
|
+
|
|
|
+ $role = $this->checkDataShare();
|
|
|
+ if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['s.apply_id', 'in', $role[DataGroupModel::$type_全部]];
|
|
|
+
|
|
|
$company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
if ($company_name !== "") $where[] = ["s.apply_id", 'in', get_company_item_user_by_name($company_name)];
|
|
|
// if(!empty($role['platform']) ){
|
|
|
// $where[]=["s.platform_id","in",$role['platform']];
|
|
|
// }
|
|
|
- $count = Db::name('sale')->alias('s')->where($where)->count();
|
|
|
+ $count = Db::name('sale')
|
|
|
+ ->alias('s')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=s.apply_id AND u.is_del=0")->where($where)
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
$list = Db::name('sale')
|
|
@@ -2134,6 +2143,11 @@ class Sale extends Base
|
|
|
$value['send_num'] -= $value['th_num'];
|
|
|
$value['total_price'] = round($value['total_price'] - $value['th_fee'], 2);
|
|
|
$value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
+
|
|
|
+ //是否具有编辑权限
|
|
|
+ $value['is_allow_update'] = 0;
|
|
|
+ if (in_array($this->roleid, [1, 33]) || in_array($value['apply_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
|
|
|
+
|
|
|
$data[] = $value;
|
|
|
}
|
|
|
return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|
|
@@ -3015,20 +3029,29 @@ class Sale extends Base
|
|
|
// if(!empty($role['write'])){
|
|
|
// $where[]=["apply_id","in",$role['write']];
|
|
|
// }
|
|
|
+ $role = $this->checkDataShare();
|
|
|
+ if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['c.apply_id', 'in', $role[DataGroupModel::$type_全部]];
|
|
|
+
|
|
|
// if(!empty($role['platform']) ){
|
|
|
// $where[]=["c.platform_id","in",$role['platform']];
|
|
|
// }
|
|
|
- $count = Db::name('sale_diff')->alias('a')
|
|
|
+ $count = Db::name('sale_diff')
|
|
|
+ ->alias('a')
|
|
|
->join("sale c", "c.orderCode=a.orderCode", "left")
|
|
|
->join("customer_info v", "v.companyNo=c.customer_code", "left")
|
|
|
->where($where)->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? intval($total) : $page;
|
|
|
- $list = Db::name('sale_diff')->alias('a')
|
|
|
+ $list = Db::name('sale_diff')
|
|
|
+ ->alias('a')
|
|
|
+ ->field("a.*,c.customer_code,v.companyName,c.skuCode,c.order_type,c.supplierNo,c.apply_id")
|
|
|
->join("sale c", "c.orderCode=a.orderCode", "left")
|
|
|
->join("customer_info v", "v.companyNo=c.customer_code", "left")
|
|
|
- ->where($where)->page($page, $size)->field("a.*,c.customer_code,v.companyName,c.skuCode,c.order_type,c.supplierNo")
|
|
|
- ->order("a.addtime desc")->select();
|
|
|
+ ->where($where)
|
|
|
+ ->page($page, $size)
|
|
|
+ ->order("a.addtime desc")
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
|
|
|
$data = [];
|
|
|
foreach ($list as $value) {
|
|
@@ -3042,6 +3065,11 @@ class Sale extends Base
|
|
|
$wsm = Db::name("business")->where(['companyNo' => $value['supplierNo']])->find();
|
|
|
$value['supplierNo'] = isset($wsm['companyNo']) ? $wsm['companyNo'] : "";
|
|
|
$value['supplierName'] = isset($wsm['company']) ? $wsm['company'] : "";
|
|
|
+
|
|
|
+ //是否具有编辑权限
|
|
|
+ $value['is_allow_update'] = 0;
|
|
|
+ if (in_array($this->roleid, [1, 33]) || in_array($value['apply_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
|
|
|
+
|
|
|
$data[] = $value;
|
|
|
}
|
|
|
return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|
|
@@ -3300,13 +3328,17 @@ class Sale extends Base
|
|
|
if ($cgdNo != "") {
|
|
|
$where[] = ["os.cgdNo", 'like', '%' . $cgdNo . '%'];
|
|
|
}
|
|
|
- $role = $this->checkRole();
|
|
|
+// $role = $this->checkRole();
|
|
|
$condition = '';
|
|
|
- if (!empty($role['write']) && $this->uid != "") {
|
|
|
- // $where[]=["a.apply_id","in",$role['write']];
|
|
|
- $condition .= " (b.is_stock=1 and n.contactor = {$this->uid}) or (b.is_stock=0 and wpo.cgder_id = {$this->uid}) or a.apply_id in (" . implode(',',
|
|
|
- $role['write']) . ")";
|
|
|
- }
|
|
|
+// if (!empty($role['write']) && $this->uid != "") {
|
|
|
+// // $where[]=["a.apply_id","in",$role['write']];
|
|
|
+// $condition .= " (b.is_stock=1 and n.contactor = {$this->uid}) or (b.is_stock=0 and wpo.cgder_id = {$this->uid}) or a.apply_id in (" . implode(',',
|
|
|
+// $role['write']) . ")";
|
|
|
+// }
|
|
|
+
|
|
|
+ $role = $this->checkDataShare();
|
|
|
+ if (!empty($role[DataGroupModel::$type_全部])) $condition .= " (b.is_stock=1 and n.contactor = {$this->uid}) or (b.is_stock=0 and wpo.cgder_id = {$this->uid}) or a.apply_id in (" . implode(',', $role[DataGroupModel::$type_全部]) . ")";
|
|
|
+
|
|
|
// if(!empty($role['platform']) ){
|
|
|
// $where[]=["b.platform_id","in",$role['platform']];
|
|
|
// }
|
|
@@ -3378,6 +3410,11 @@ class Sale extends Base
|
|
|
$value['can'] = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
|
|
|
$value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
|
|
|
$value['sendtime'] = $value['status'] < 2 ? '' : $value['sendtime'];
|
|
|
+
|
|
|
+ //是否具有编辑权限
|
|
|
+ $value['is_allow_update'] = 0;
|
|
|
+ if (in_array($this->roleid, [1, 33]) || in_array($value['apply_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
|
|
|
+
|
|
|
$data[] = $value;
|
|
|
}
|
|
|
return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|