|
|
@@ -36,6 +36,9 @@ use JinDouYun\Model\Finance\MRefund;
|
|
|
use JinDouYun\Dao\Purchase\DPurchase;
|
|
|
use JinDouYun\Dao\Purchase\DPurchaseGoods;
|
|
|
use JinDouYun\Dao\Stock\DInventory;
|
|
|
+
|
|
|
+use JinDouYun\Dao\Shop\DShop;
|
|
|
+
|
|
|
use Mall\Framework\Factory;
|
|
|
use const Grpc\STATUS_ABORTED;
|
|
|
|
|
|
@@ -56,7 +59,7 @@ class MPurchase extends MBaseModel
|
|
|
private $objStock;
|
|
|
|
|
|
private $cutTable = 200000;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* MOrder constructor.
|
|
|
@@ -735,7 +738,9 @@ class MPurchase extends MBaseModel
|
|
|
$groupBySql = ' GROUP BY p.supplierId,g.basicGoodsId';
|
|
|
} elseif ($type == 3) {//采购人员
|
|
|
$groupBySql = ' GROUP BY p.buyerId,g.basicGoodsId';
|
|
|
- } else {
|
|
|
+ } elseif($type==4){
|
|
|
+ $groupBySql = ' GROUP BY p.shopId,g.basicGoodsId';
|
|
|
+ }else {
|
|
|
return ResultWrapper::fail('type参数错误', ErrorCode::$paramError);
|
|
|
}
|
|
|
|
|
|
@@ -772,7 +777,12 @@ class MPurchase extends MBaseModel
|
|
|
//统计已审核 未删除主单据 未删除详情 的采购订单
|
|
|
$where = empty($whereSql) ? ' WHERE ' : ' AND ';
|
|
|
$whereSql .= $where . ' p.auditStatus = ' . StatusCode::$auditStatus['auditPass'] . ' AND p.deleteStatus = ' . StatusCode::$standard . ' AND g.deleteStatus = ' . StatusCode::$standard;
|
|
|
- $sql = 'SELECT p.warehouseId,p.warehouseName,p.id,p.`no`,p.buyerId,p.buyerName,p.supplierId,p.supplierName,p.operatorId,p.operatorName,p.inStatus,g.skuId,g.categoryId,g.categoryName,g.basicGoodsId AS materielId,g.goodsName AS materielName,g.goodsCode AS materielCode,SUM(g.buyerNum) AS allNum,SUM(g.subtotalPrice) AS total,(SUM(g.subtotalPrice) / SUM(g.buyerNum)) AS costPrice, SUM(g.otherNum) AS otherNum FROM ' . $this->objDPurchase->get_Table() . ' p LEFT JOIN ' . $this->objDPurchaseGoods->get_Table() . ' g ON p.id = g.purchaseId ' . $whereSql . ' ' . $groupBySql . ' ORDER BY p.createTime DESC LIMIT ' . $offset . ' , ' . $limit;
|
|
|
+ $sql = 'SELECT p.warehouseId,p.warehouseName,p.id,p.`no`,p.buyerId,p.buyerName,p.supplierId,p.supplierName,p.operatorId,p.operatorName,p.inStatus,s.name as shopName,g.skuId,g.categoryId,g.categoryName,g.basicGoodsId AS materielId,g.goodsName AS materielName,g.goodsCode AS materielCode,SUM(g.buyerNum) AS allNum,SUM(g.subtotalPrice) AS total,(SUM(g.subtotalPrice) / SUM(g.buyerNum)) AS costPrice, SUM(g.otherNum) AS otherNum '
|
|
|
+ . 'FROM ' . $this->objDPurchase->get_Table() . ' p '
|
|
|
+ . 'LEFT JOIN qianniao_shop_1 s ON s.id = p.shopId '
|
|
|
+ . 'LEFT JOIN ' . $this->objDPurchaseGoods->get_Table() . ' g ON p.id = g.purchaseId '
|
|
|
+ . $whereSql . ' ' . $groupBySql . ' '
|
|
|
+ . 'ORDER BY p.createTime DESC LIMIT ' . $offset . ' , ' . $limit;
|
|
|
|
|
|
$dbResult = $this->objDPurchase->query($sql);
|
|
|
if ($dbResult === false) {
|
|
|
@@ -780,7 +790,9 @@ class MPurchase extends MBaseModel
|
|
|
}
|
|
|
$selectData = $dbResult;
|
|
|
unset($dbResult);
|
|
|
- $totalSql = 'SELECT COUNT(id) AS total FROM (SELECT p.id FROM ' . $this->objDPurchase->get_Table() . ' p LEFT JOIN ' . $this->objDPurchaseGoods->get_Table() . ' g ON p.id = g.purchaseId ' . $whereSql . ' ' . $groupBySql . ') AS selectData';
|
|
|
+ $totalSql = 'SELECT COUNT(id) AS total FROM (SELECT p.id FROM ' . $this->objDPurchase->get_Table() . ' p '
|
|
|
+ . 'LEFT JOIN qianniao_shop_1 s ON s.id = p.shopId '
|
|
|
+ . 'LEFT JOIN ' . $this->objDPurchaseGoods->get_Table() . ' g ON p.id = g.purchaseId ' . $whereSql . ' ' . $groupBySql . ') AS selectData';
|
|
|
$dbResult = $this->objDPurchase->query($totalSql);
|
|
|
if ($dbResult === false) {
|
|
|
return ResultWrapper::fail($this->objDPurchase->error(), ErrorCode::$dberror);
|