|
|
@@ -728,6 +728,7 @@ class MPurchase extends MBaseModel
|
|
|
*/
|
|
|
public function getAllPurchaseByFields($selectParams, $type ,$export = 0)
|
|
|
{
|
|
|
+ $defaultDbName = Factory::config()->get('db.default.dbname');
|
|
|
$limit = $selectParams['limit'];
|
|
|
unset($selectParams['limit']);
|
|
|
$offset = $selectParams['offset'];
|
|
|
@@ -786,7 +787,7 @@ class MPurchase extends MBaseModel
|
|
|
$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,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 '.$this->objDShop->get_Table().' s ON s.id = p.shopId '
|
|
|
+ . 'LEFT JOIN `'.$defaultDbName.'`.'.$this->objDShop->get_Table().' 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;
|
|
|
@@ -798,7 +799,7 @@ 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->objDShop->get_Table().' s ON s.id = p.shopId '
|
|
|
+ . 'LEFT JOIN `'.$defaultDbName.'`.'.$this->objDShop->get_Table().' 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) {
|