|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace bizGhs\order\classes;
|
|
|
|
|
|
+use bizGhs\product\classes\ProductClass;
|
|
|
use bizTy\sj\classes\MerchantAssetClass;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
@@ -14,10 +15,10 @@ use bizGhs\base\classes\BaseClass;
|
|
|
|
|
|
class OrderClass extends BaseClass
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
public static $baseFile = '\bizGhs\order\models\Order';
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//已完成
|
|
|
const ORDER_STATUS_COMPLETE = 6;
|
|
|
//已取消
|
|
|
@@ -30,8 +31,8 @@ class OrderClass extends BaseClass
|
|
|
const ORDER_STATUS_UN_SEND = 2;
|
|
|
//待付款,待确认
|
|
|
const ORDER_STATUS_UN_PAY = 1;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//未确认
|
|
|
const SEND_TYPE_UNKNOWN = 1;
|
|
|
//自取
|
|
|
@@ -40,25 +41,25 @@ class OrderClass extends BaseClass
|
|
|
const SEND_TYPE_MYSELF = 3;
|
|
|
//快递送,第三方配送
|
|
|
const SEND_TYPE_THIRD = 4;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//待付款,待确认
|
|
|
const PAY_STATUS_UN_PAY = 1;
|
|
|
//已付款
|
|
|
const PAY_STATUS_HAS_PAY = 2;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//待配送
|
|
|
const SEND_STATUS_UN_SEND = 1;
|
|
|
//配送中
|
|
|
const SEND_STATUS_SENDING = 2;
|
|
|
//配送完成
|
|
|
const SEND_STATUS_COMPLETE = 3;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//订单总流程数
|
|
|
const TOTAL_FLOW = 3;
|
|
|
-
|
|
|
+
|
|
|
//添加订单 shish 2019.12.5
|
|
|
public static function addOrder($data)
|
|
|
{
|
|
|
@@ -67,11 +68,11 @@ class OrderClass extends BaseClass
|
|
|
$orderSn = orderSn::getGhsOrderSn();
|
|
|
$data['orderSn'] = $orderSn;
|
|
|
$data['payStatus'] = self::PAY_STATUS_UN_PAY;
|
|
|
-
|
|
|
+
|
|
|
//花材列表
|
|
|
$product = $data['product'];
|
|
|
OrderItemClass::replace($orderSn, $product);
|
|
|
-
|
|
|
+
|
|
|
//将花店每月的总订单数作为编号
|
|
|
$riseNum = StatOrderCountClass::addOrder($month, $merchantId);
|
|
|
$data['sendNum'] = $riseNum;
|
|
|
@@ -82,27 +83,31 @@ class OrderClass extends BaseClass
|
|
|
$data['deadline'] = date("Y-m-d H:i:s", (time() + 1800));
|
|
|
$return = self::add($data);
|
|
|
$orderId = $return['id'];
|
|
|
-
|
|
|
+
|
|
|
//全部订单+1,待付款订单+1
|
|
|
$merchantAsset = MerchantAssetClass::getByMerchantId($merchantId, true);
|
|
|
$merchantAsset->unPayOrder += 1;
|
|
|
$merchantAsset->totalOrder += 1;
|
|
|
$merchantAsset->save();
|
|
|
-
|
|
|
+
|
|
|
//增加下单流程
|
|
|
$payTime = date("Y-m-d H:i:s");
|
|
|
$sendData = ['orderId' => $orderId, 'orderSn' => $orderSn, 'payTime' => $payTime];
|
|
|
OrderSendClass::placeOrder($sendData);
|
|
|
-
|
|
|
+
|
|
|
+ //扣库存 2021.2.23 linqh
|
|
|
+ foreach ($product as $key => $val) {
|
|
|
+ ProductClass::decreaseStock($val['productId'],$val['bigNum'],$val['smallNum']);
|
|
|
+ }
|
|
|
return $return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//根据订单编号查询 shish 2021.19
|
|
|
public static function getByOrderSn($orderSn)
|
|
|
{
|
|
|
return self::getByCondition(['orderSn' => $orderSn]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//订单列表 shish 2021.1.19
|
|
|
public static function getOrderList($where)
|
|
|
{
|
|
|
@@ -115,20 +120,20 @@ class OrderClass extends BaseClass
|
|
|
$data['finishNum'] = 0;
|
|
|
return $data;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//整合订单员工和供货商等信息 shish 2021.1.19
|
|
|
public static function groupOrder($list, $showButton = false, $showProgress = false, $showProduct = false)
|
|
|
{
|
|
|
if (empty($list)) {
|
|
|
return $list;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$customIds = array_unique(array_filter(array_column($list, 'customId')));
|
|
|
$customInfo = CustomClass::getCustomByIds($customIds);
|
|
|
-
|
|
|
+
|
|
|
$adminIds = array_unique(array_filter(array_column($list, 'adminId')));
|
|
|
$adminInfo = AdminClass::getAdminByIds($adminIds, null, 'id');
|
|
|
-
|
|
|
+
|
|
|
foreach ($list as $key => $val) {
|
|
|
$adminId = $val['adminId'] ?? 0;
|
|
|
$list[$key]['adminName'] = $adminInfo[$adminId]['adminName'] ?? '';
|
|
|
@@ -162,7 +167,7 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
return $list;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static function valid($info, $shopId)
|
|
|
{
|
|
|
if (isset($info['shopId']) && $info['shopId'] == $shopId) {
|
|
|
@@ -170,7 +175,7 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
util::fail('没有权限操作的订单');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//获取订单详情 shish 2021.1.21
|
|
|
public static function getOrderInfo($id, $showButton = false, $showProgress = false, $showProduct = false)
|
|
|
{
|
|
|
@@ -178,7 +183,7 @@ class OrderClass extends BaseClass
|
|
|
$respond = self::groupOrder([$info], $showButton, $showProgress, $showProduct);
|
|
|
return current($respond);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//订单到期未付款未确认的订单置成取消状态 shish 2021.1.23
|
|
|
public static function setExpire($order)
|
|
|
{
|
|
|
@@ -190,7 +195,7 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//本店送 shish 2021.1.24
|
|
|
public static function selfSend($info)
|
|
|
{
|
|
|
@@ -206,7 +211,7 @@ class OrderClass extends BaseClass
|
|
|
'sendType' => self::SEND_TYPE_MYSELF,
|
|
|
]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//自取和免发货流程的处理 shish 2021.1.24
|
|
|
public static function withoutSend($order)
|
|
|
{
|
|
|
@@ -214,28 +219,28 @@ class OrderClass extends BaseClass
|
|
|
if ($order['status'] == self::ORDER_STATUS_COMPLETE) {
|
|
|
util::fail('订单已完成');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//订单状态变更
|
|
|
self::updateById($id, ['sendType' => self::SEND_TYPE_NO, 'totalFlow' => OrderClass::TOTAL_FLOW, 'currentFlow' => OrderClass::TOTAL_FLOW]);
|
|
|
self::complete($order, self::TOTAL_FLOW);
|
|
|
-
|
|
|
+
|
|
|
OrderSendClass::withoutSend($order);
|
|
|
-
|
|
|
+
|
|
|
//待发货订单-1,完成订单+1
|
|
|
$merchantId = $order['merchantId'];
|
|
|
$asset = MerchantAssetClass::getByMerchantId($merchantId, true);
|
|
|
$asset->finishOrder += 1;
|
|
|
$asset->unSendOrder -= 1;
|
|
|
$asset->save();
|
|
|
-
|
|
|
+
|
|
|
return self::TOTAL_FLOW;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//订单完成 shish 2020.3.12
|
|
|
public static function complete($order, $currentFlow)
|
|
|
{
|
|
|
$id = $order['id'];
|
|
|
self::updateById($id, ['status' => OrderClass::ORDER_STATUS_COMPLETE, 'currentFlow' => $currentFlow]);
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+
|
|
|
+}
|