|
|
@@ -5,13 +5,18 @@ namespace bizGhs\custom\classes;
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
use biz\sj\classes\MerchantClass;
|
|
|
use bizGhs\custom\models\Custom;
|
|
|
+use bizGhs\ghs\classes\GhsBalanceChangeClass;
|
|
|
use bizGhs\shop\classes\MainClass;
|
|
|
use bizGhs\shop\classes\TotalDebtChangeClass;
|
|
|
+use bizGhs\ghs\classes\GhsBalanceClass;
|
|
|
+use bizGhs\ghs\classes\GhsRechargeClass;
|
|
|
+use bizGhs\shop\classes\ShopClass;
|
|
|
use common\components\business;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
+use common\components\orderSn;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
class CustomClass extends BaseClass
|
|
|
@@ -58,6 +63,221 @@ class CustomClass extends BaseClass
|
|
|
self::LEVEL_ZS => 'zsAddPrice',
|
|
|
];
|
|
|
|
|
|
+ //消费余额 ssh 20240311
|
|
|
+ public static function clearConsumeBalance($amount, $custom, $ghs, $shop, $staff, $clear)
|
|
|
+ {
|
|
|
+ $customId = $custom->id ?? 0;
|
|
|
+ $ghsId = $ghs->id ?? 0;
|
|
|
+ $relateId = $clear->id ?? 0;
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $clearSn = $clear->orderSn;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+
|
|
|
+ $newGhsBalance = bcsub($ghs->balance, $amount, 2);
|
|
|
+ $ghs->balance = $newGhsBalance;
|
|
|
+ $ghs->save();
|
|
|
+
|
|
|
+ $newCustomBalance = bcsub($custom->balance, $amount, 2);
|
|
|
+ $custom->balance = $newCustomBalance;
|
|
|
+ $custom->save();
|
|
|
+
|
|
|
+ if ($newGhsBalance < 0) {
|
|
|
+ util::fail('余额有问题哦..');
|
|
|
+ }
|
|
|
+ if (floatval($newGhsBalance) != floatval($newCustomBalance)) {
|
|
|
+ util::fail('余额有问题...');
|
|
|
+ }
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'ghsHelpCustomUseBalanceClear', 'id');
|
|
|
+ $fromType = dict::getDict('fromType', 'shop');
|
|
|
+ $cbData = [
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $newCustomBalance,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'io' => 0,
|
|
|
+ 'side' => 0,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => '结账 ' . $clearSn,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ $cbc = CustomBalanceChangeClass::add($cbData, true);
|
|
|
+
|
|
|
+ $customShopId = $custom->shopId ?? 0;
|
|
|
+ $customShop = ShopClass::getById($customShopId, true);
|
|
|
+ if (empty($customShop)) {
|
|
|
+ util::fail('没有找到客户门店呢..');
|
|
|
+ }
|
|
|
+ $customShopSjId = $customShop->sjId ?? 0;
|
|
|
+ $customShopMainId = $customShop->mainId ?? 0;
|
|
|
+ $capitalType = dict::getDict('capitalType', 'customAskGhsUseBalanceClear', 'id');
|
|
|
+ $gbData = [
|
|
|
+ 'ghsId' => $ghsId,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $newGhsBalance,
|
|
|
+ 'io' => 0,
|
|
|
+ 'side' => 0,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => '结账 ' . $clearSn,
|
|
|
+ 'sjId' => $customShopSjId,
|
|
|
+ 'mainId' => $customShopMainId,
|
|
|
+ 'shopId' => $customShopId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ $gbc = GhsBalanceChangeClass::add($gbData, true);
|
|
|
+
|
|
|
+ $clear->customBalanceChangeId = $cbc->id ?? 0;
|
|
|
+ $clear->ghsBalanceChangeId = $gbc->id ?? 0;
|
|
|
+ $clear->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ //充值金额 ssh 20240310
|
|
|
+ public static function rechargeBalance($custom, $amount, $shop, $staff, $payWay)
|
|
|
+ {
|
|
|
+ $ghsId = $custom->ghsId ?? 0;
|
|
|
+ $ghsInfo = GhsClass::getLockById($ghsId);
|
|
|
+ if (empty($ghsInfo)) {
|
|
|
+ util::fail('没有找到供货商');
|
|
|
+ }
|
|
|
+ $ghsShopId = $ghsInfo->shopId ?? 0;
|
|
|
+ $ghsName = $ghsInfo->name ?? '';
|
|
|
+ $customId = $custom->id ?? 0;
|
|
|
+ $customShopId = $custom->shopId ?? 0;
|
|
|
+ $customName = $custom->name ?? '';
|
|
|
+ $customShop = ShopClass::getById($customShopId, true);
|
|
|
+ if (empty($customShop)) {
|
|
|
+ util::fail('没有找到客户门店');
|
|
|
+ }
|
|
|
+ $customShopSjId = $customShop->sjId ?? 0;
|
|
|
+ $customShopMainId = $customShop->mainId ?? 0;
|
|
|
+
|
|
|
+ $payMap = dict::getDict('payWayName');
|
|
|
+ $payName = $payMap[$payWay] ?? '';
|
|
|
+ $rechargeEvent = $payName . '充值';
|
|
|
+
|
|
|
+ $custom->balance = bcadd($custom->balance, $amount, 2);
|
|
|
+ $custom->save();
|
|
|
+ $orderSn = orderSn::getGhsCustomRechargeSn();
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $cData = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $custom->balance,
|
|
|
+ 'side' => 0,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'payStatus' => 1,
|
|
|
+ 'status' => 1,
|
|
|
+ 'remark' => '',
|
|
|
+ 'ghsId' => $ghsId,
|
|
|
+ 'ghsShopId' => $ghsShopId,
|
|
|
+ 'ghsName' => $ghsName,
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customShopId' => $customShopId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ ];
|
|
|
+ $cRecharge = CustomRechargeClass::add($cData, true);
|
|
|
+ $cRechargeId = $cRecharge->id ?? 0;
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'ghsHelpCustomRecharge', 'id');
|
|
|
+ $fromType = dict::getDict('fromType', 'shop');
|
|
|
+ $cbData = [
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'relateId' => $cRechargeId,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $custom->balance,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => 0,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => $rechargeEvent,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ CustomBalanceChangeClass::add($cbData, true);
|
|
|
+
|
|
|
+ $ghsInfo->balance = bcadd($ghsInfo->balance, $amount, 2);
|
|
|
+ $ghsInfo->save();
|
|
|
+ $orderSn = orderSn::getGhsRechargeSn();
|
|
|
+ $customMainId = $custom->mainId ?? 0;
|
|
|
+ $gData = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'shopId' => $customShopId,
|
|
|
+ 'mainId' => $customMainId,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $ghsInfo->balance,
|
|
|
+ 'side' => 0,
|
|
|
+ 'staffId' => 0,
|
|
|
+ 'staffName' => '',
|
|
|
+ 'payStatus' => 1,
|
|
|
+ 'status' => 1,
|
|
|
+ 'remark' => '',
|
|
|
+ 'ghsId' => $ghsId,
|
|
|
+ 'ghsShopId' => $ghsShopId,
|
|
|
+ 'ghsName' => $ghsName,
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customShopId' => $customShopId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ ];
|
|
|
+ $gRecharge = GhsRechargeClass::add($gData, true);
|
|
|
+ $gRechargeId = $gRecharge->id ?? 0;
|
|
|
+ $capitalType = dict::getDict('capitalType', 'customAskGhsRecharge', 'id');
|
|
|
+ $gbData = [
|
|
|
+ 'ghsId' => $ghsId,
|
|
|
+ 'relateId' => $gRechargeId,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $ghsInfo->balance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => 0,
|
|
|
+ 'onlinePay' => 1,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => $rechargeEvent,
|
|
|
+ 'sjId' => $customShopSjId,
|
|
|
+ 'mainId' => $customShopMainId,
|
|
|
+ 'shopId' => $customShopId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ GhsBalanceChangeClass::add($gbData, true);
|
|
|
+ return ['custom' => $custom, 'ghs' => $ghsInfo];
|
|
|
+ }
|
|
|
+
|
|
|
public static function createSeatSn($mainId)
|
|
|
{
|
|
|
$max = Custom::find(['mainId' => $mainId])->max('seatSn');
|