|
@@ -1787,37 +1787,37 @@ class Sale extends Base
|
|
|
{
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
|
|
|
$size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
|
|
|
- $where[] = ['is_del', "=", 0];
|
|
|
+ $where[] = ['s.is_del', "=", 0];
|
|
|
$orderCode = isset($this->post['orderCode']) && $this->post['orderCode'] !== "" ? trim($this->post['orderCode']) : "";
|
|
|
if ($orderCode !== "") {
|
|
|
- $where[] = ['orderCode', "like", "%$orderCode%"];
|
|
|
+ $where[] = ['s.orderCode', "like", "%$orderCode%"];
|
|
|
}
|
|
|
$apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !== "" ? trim($this->post['apply_name'])
|
|
|
: "";
|
|
|
if ($apply_name !== "") {
|
|
|
- $where[] = ['apply_name', "like", "%$apply_name%"];
|
|
|
+ $where[] = ['s.apply_name', "like", "%$apply_name%"];
|
|
|
}
|
|
|
$good_name = isset($this->post['good_name']) && $this->post['good_name'] !== "" ? trim($this->post['good_name'])
|
|
|
: "";
|
|
|
if ($good_name !== "") {
|
|
|
- $where[] = ['good_name', "like", "%$good_name%"];
|
|
|
+ $where[] = ['s.good_name', "like", "%$good_name%"];
|
|
|
}
|
|
|
$good_code = isset($this->post['good_code']) && $this->post['good_code'] !== "" ? trim($this->post['good_code']) : "";
|
|
|
if ($good_code !== "") {
|
|
|
- $where[] = ['good_code', "like", "%$good_code%"];
|
|
|
+ $where[] = ['s.good_code', "like", "%$good_code%"];
|
|
|
}
|
|
|
$customer_code = isset($this->post['customer_code']) && $this->post['customer_code'] !== "" ? trim($this->post['customer_code']) : "";
|
|
|
if ($customer_code !== "") {
|
|
|
- $where[] = ['customer_code', "like", "%$customer_code%"];
|
|
|
+ $where[] = ['s.customer_code', "like", "%$customer_code%"];
|
|
|
}
|
|
|
$supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !== "" ? trim($this->post['supplierNo']) : "";
|
|
|
if ($supplierNo !== "") {
|
|
|
- $where[] = ['supplierNo', "like", "%$supplierNo%"];
|
|
|
+ $where[] = ['s.supplierNo', "like", "%$supplierNo%"];
|
|
|
}
|
|
|
$ordertype = isset($this->post['order_type']) && $this->post['order_type'] !== "" ? intval($this->post['order_type'])
|
|
|
: "";
|
|
|
if ($ordertype !== "") {
|
|
|
- $where[] = ['order_type', "=", $ordertype];
|
|
|
+ $where[] = ['s.order_type', "=", $ordertype];
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
|
|
|
if ($status !== "") {
|
|
@@ -1825,23 +1825,31 @@ class Sale extends Base
|
|
|
}
|
|
|
$start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
|
|
|
if ($start != "") {
|
|
|
- $where[] = ["addtime", '>=', $start];
|
|
|
+ $where[] = ["s.addtime", '>=', $start];
|
|
|
}
|
|
|
$end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
|
|
|
if ($end != "") {
|
|
|
- $where[] = ["addtime", '<=', $end];
|
|
|
+ $where[] = ["s.addtime", '<=', $end];
|
|
|
}
|
|
|
$role=$this->checkRole();
|
|
|
if(!empty($role['write'])){
|
|
|
- $where[]=["apply_id","in",$role['write']];
|
|
|
+ $where[]=["s.apply_id","in",$role['write']];
|
|
|
}
|
|
|
+ $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[]=["platform_id","in",$role['platform']];
|
|
|
+// $where[]=["s.platform_id","in",$role['platform']];
|
|
|
// }
|
|
|
- $count = Db::name('sale')->where($where)->count();
|
|
|
+ $count = Db::name('sale')->alias('s')->where($where)->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
- $list = Db::name('sale')->where($where)->order("addtime desc")->page($page, $size)->select();
|
|
|
+ $list = Db::name('sale')
|
|
|
+ ->alias('s')
|
|
|
+ ->field('s.*,u.itemid')
|
|
|
+ ->leftJoin("depart_user u", "u.uid=s.apply_id AND u.is_del=0")->where($where)
|
|
|
+ ->order("s.addtime desc")
|
|
|
+ ->page($page, $size)
|
|
|
+ ->cursor();
|
|
|
$data = [];
|
|
|
foreach ($list as $value) {
|
|
|
if($value['order_type']==3|| $value['order_type']==4){
|
|
@@ -1890,6 +1898,7 @@ class Sale extends Base
|
|
|
$value['good_num']-=$value['th_num'];
|
|
|
$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'));
|
|
|
$data[] = $value;
|
|
|
}
|
|
|
return app_show(0, "获取成功", ['list' => $data, 'count' => $count]);
|