|
|
@@ -4,14 +4,13 @@ namespace bizHd\px\classes;
|
|
|
|
|
|
use biz\shop\classes\ShopCapitalClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
-use biz\sj\classes\SjCapitalClass;
|
|
|
-use bizHd\custom\classes\CustomClass;
|
|
|
use bizHd\stat\classes\StatStudentClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
+use bizHd\base\classes\BaseClass;
|
|
|
use common\components\orderSn;
|
|
|
+use common\components\util;
|
|
|
use Yii;
|
|
|
-use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
class PxApplyClass extends BaseClass
|
|
|
{
|
|
|
@@ -23,30 +22,10 @@ class PxApplyClass extends BaseClass
|
|
|
//已付款
|
|
|
const STATUS_CONFIRM = 2;
|
|
|
|
|
|
- //培训报名 ssh 2021.3.17
|
|
|
- public static function addApply($data, $shop)
|
|
|
+ public static function addApply($data, $returnObj = false)
|
|
|
{
|
|
|
$data['orderSn'] = orderSn::getPxApplySn();
|
|
|
- StatStudentClass::addStudent($shop);
|
|
|
- $shopId = $shop['id'];
|
|
|
- $totalIncome = bcadd($shop['totalIncome'], $data['actPrice'], 2);
|
|
|
- ShopClass::updateById($shopId, ['totalIncome' => $totalIncome]);
|
|
|
- $capitalType = dict::getDict('capitalType', 'pxApply', 'id');
|
|
|
- $payWay = $data['payWay'] ?? 0;
|
|
|
- $sjId = $shop['merchantId'] ?? 0;
|
|
|
- $shopId = $shop['id'] ?? 0;
|
|
|
- $capitalData = [
|
|
|
- 'capitalType' => $capitalType,
|
|
|
- 'io' => 1,
|
|
|
- 'totalIncome' => $totalIncome,
|
|
|
- 'payWay' => $payWay,
|
|
|
- 'amount' => $data['actPrice'],
|
|
|
- 'sjId' => $sjId,
|
|
|
- 'shopId' => $shopId,
|
|
|
- ];
|
|
|
- ShopCapitalClass::addCapital($capitalData);
|
|
|
-
|
|
|
- return self::add($data);
|
|
|
+ return PxApplyClass::add($data, $returnObj);
|
|
|
}
|
|
|
|
|
|
//学员管理 ssh 2021.3.17
|
|
|
@@ -78,4 +57,48 @@ class PxApplyClass extends BaseClass
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
+ //订单完成 shish 20210523
|
|
|
+ public static function complete($order, $payWay)
|
|
|
+ {
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ if (isset($order->status) == false || $order->status != self::STATUS_UN_CONFIRM) {
|
|
|
+ util::fail('订单不是待确认状态');
|
|
|
+ }
|
|
|
+ $order->status = self::STATUS_CONFIRM;
|
|
|
+ $order->payWay = $payWay;
|
|
|
+ $order->save();
|
|
|
+
|
|
|
+ $actPrice = $order->actPrice ?? 0;
|
|
|
+ $shopId = $order->shopId;
|
|
|
+ $shop = ShopClass::getLockById($shopId);
|
|
|
+ if (empty($shop)) {
|
|
|
+ Yii::info("没有找到门店 PxApplyClass::complete() orderId:{$order->id}");
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $currentTotalIncome = bcadd($shop->totalIncome, $actPrice, 2);
|
|
|
+ $shop->totalIncome = $currentTotalIncome;
|
|
|
+ $shop->studentNum += 1;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'pxApply', 'id');
|
|
|
+ $sjId = $order->sjId ?? 0;
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $event = '学员报名';
|
|
|
+ $capitalData = [
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'io' => 1,
|
|
|
+ 'totalIncome' => $currentTotalIncome,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'amount' => $actPrice,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'event' => $event,
|
|
|
+ ];
|
|
|
+ ShopCapitalClass::addCapital($capitalData);
|
|
|
+ //增加新学员数量
|
|
|
+ StatStudentClass::addStudent($shop);
|
|
|
+ }
|
|
|
+
|
|
|
}
|