|
|
@@ -8,6 +8,7 @@ use biz\shop\models\Shop;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
use bizGhs\custom\models\Custom;
|
|
|
+use bizGhs\order\classes\OrderSendClass;
|
|
|
use bizGhs\order\traits\OrderTrait;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
@@ -313,6 +314,7 @@ class PurchaseClass extends BaseClass
|
|
|
$ghsOrder->status = OrderClass::ORDER_STATUS_UN_SEND;
|
|
|
$ghsOrder->debt = OrderClass::DEBT_YES;
|
|
|
$ghsOrder->save();
|
|
|
+ /**供货商门店资产变化**/
|
|
|
$shopId = $ghsOrder->shopId;
|
|
|
$actPrice = $ghsOrder->actPrice;
|
|
|
$shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
@@ -321,7 +323,13 @@ class PurchaseClass extends BaseClass
|
|
|
}
|
|
|
$shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
|
|
|
$shop->totalOrderNum += 1;
|
|
|
+ $shop->unPayOrder -= 1;
|
|
|
+ $shop->unSendOrder += 1;
|
|
|
$shop->save();
|
|
|
+ //自取订单,订单直接完成,【现在有三个地方有订单完成操作】,找不到请搜索【】内关键词。
|
|
|
+ if (isset($ghsOrder->sendType) && $ghsOrder->sendType == OrderClass::SEND_TYPE_NO) {
|
|
|
+ OrderClass::withoutSend($ghsOrder->attributes);
|
|
|
+ }
|
|
|
|
|
|
/**供货商的客户资产变化**/
|
|
|
$customId = $ghsOrder->customId;
|
|
|
@@ -338,8 +346,8 @@ class PurchaseClass extends BaseClass
|
|
|
|
|
|
/********订单完成后加库存 linqh 2021-05-10*********/
|
|
|
$orderSn = $info->orderSn;
|
|
|
- $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn'=>$orderSn],null,"*");
|
|
|
- foreach ($purchaseItem as $v){
|
|
|
+ $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
|
|
|
+ foreach ($purchaseItem as $v) {
|
|
|
ProductClass::addStockByItemNum($v['productId'], $v['itemNum']);
|
|
|
}
|
|
|
}
|
|
|
@@ -351,33 +359,33 @@ class PurchaseClass extends BaseClass
|
|
|
$order->save();
|
|
|
//供货商那边加回库存
|
|
|
$orderSn = $order->orderSn;
|
|
|
- $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn'=>$orderSn],null,"*");
|
|
|
- foreach ($purchaseItem as $v){
|
|
|
+ $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
|
|
|
+ foreach ($purchaseItem as $v) {
|
|
|
ProductClass::addStockByItemNum($v['ghsProductId'], $v['itemNum']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//采购统计2021-05-08
|
|
|
//采购数,采购金额统计(根据时间,今日,昨天,7天,30天)
|
|
|
- public static function statOrderInfo($shopId,$statType)
|
|
|
+ public static function statOrderInfo($shopId, $statType)
|
|
|
{
|
|
|
$start = '';
|
|
|
$end = '';
|
|
|
- switch ($statType){
|
|
|
+ switch ($statType) {
|
|
|
case "today":
|
|
|
$start = date('Y-m-d');
|
|
|
$end = $start;
|
|
|
break;
|
|
|
case "yesterday" :
|
|
|
- $start = date('Y-m-d',strtotime("-1 day"));
|
|
|
+ $start = date('Y-m-d', strtotime("-1 day"));
|
|
|
$end = $start;
|
|
|
break;
|
|
|
case "seven":
|
|
|
- $start = date('Y-m-d',strtotime("-6 day"));
|
|
|
+ $start = date('Y-m-d', strtotime("-6 day"));
|
|
|
$end = date('Y-m-d');
|
|
|
break;
|
|
|
case "thirty":
|
|
|
- $start = date('Y-m-d',strtotime("-29 day"));
|
|
|
+ $start = date('Y-m-d', strtotime("-29 day"));
|
|
|
$end = date('Y-m-d');
|
|
|
break;
|
|
|
default:
|
|
|
@@ -389,12 +397,12 @@ class PurchaseClass extends BaseClass
|
|
|
$res = self::getAllByCondition($where, null, "id,actPrice");
|
|
|
$totalAmount = 0;
|
|
|
$totalNum = count($res);
|
|
|
- foreach ($res as $v){
|
|
|
- $totalAmount = bcadd($totalAmount,$v['actPrice'],2);
|
|
|
+ foreach ($res as $v) {
|
|
|
+ $totalAmount = bcadd($totalAmount, $v['actPrice'], 2);
|
|
|
}
|
|
|
return [
|
|
|
- 'totalAmount'=>$totalAmount,
|
|
|
- 'totalNum'=>$totalNum,
|
|
|
+ 'totalAmount' => $totalAmount,
|
|
|
+ 'totalNum' => $totalNum,
|
|
|
];
|
|
|
|
|
|
}
|