| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- <?php
- namespace biz\shop\classes;
- use biz\ghs\classes\GhsClass;
- use biz\pt\classes\PtAssetClass;
- use biz\pt\classes\PtYeChangeClass;
- use biz\sj\classes\SjClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\order\classes\OrderClass;
- use bizGhs\product\classes\ProductClass;
- use bizHd\ad\classes\AdClass;
- use bizHd\goods\classes\CategoryClass;
- use bizHd\goods\classes\GoodsSettingClass;
- use bizHd\saas\classes\ApplyClass;
- use common\components\dict;
- use common\components\httpUtil;
- use common\components\imgUtil;
- use common\components\qrCodeUtil;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- use biz\base\classes\BaseClass;
- class ShopClass extends BaseClass
- {
- public static $baseFile = '\biz\shop\models\Shop';
- //营业状态
- public static function isOpen($shop)
- {
- if (isset($shop['open']) == false || $shop['open'] == 0) {
- return 0;
- }
- $openStartTime = $shop['openStartTime'] ?? '';
- if (empty($openStartTime)) {
- return 1;
- }
- $openEndTime = $shop['openEndTime'] ?? '';
- $start = strtotime(date("Y-m-d") . ' ' . $openStartTime);
- $end = strtotime(date("Y-m-d") . ' ' . $openEndTime);
- $time = time();
- if ($time > $start && $time < $end) {
- return 1;
- }
- return 0;
- }
- //获取图片信息 ssh 2021.3.14
- public static function getShopInfo($id)
- {
- $info = self::getById($id);
- if (empty($info)) {
- return $info;
- }
- $list = self::groupShopInfo([$info]);
- return current($list);
- }
- public static function getShopList($where)
- {
- $list = self::getList('*', $where, 'addTime DESC');
- return $list;
- }
- //查看店铺 ssh 2021.3.1
- public static function getShopByIds($ids)
- {
- $list = self::getByIds($ids);
- return self::groupShopInfo($list);
- }
- //门店 ssh 2021.3.1
- public static function groupShopInfo($list)
- {
- if (empty($list)) {
- return $list;
- }
- foreach ($list as $key => $val) {
- $avatar = imgUtil::groupImg($val['avatar']);
- $list[$key]['avatar'] = $avatar;
- //店长微信
- $superWx = $val['superWx'] ?? '';
- $list[$key]['superWx'] = imgUtil::groupImg($superWx) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- }
- return $list;
- }
- //获取商家默认的门店ID ssh 2020.1.19
- public static function getDefaultShopId($merchant)
- {
- return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
- }
- //更新门店 ssh 2020.2.29
- public static function updateShop($shop, $data)
- {
- $id = $shop['id'] ?? 0;
- $shopName = isset($data['shopName']) ? $data['shopName'] : '';
- if (stringUtil::getWordNum($shopName) > 8) {
- util::fail('门店名称不能超过8个汉字,2个字母顶一个汉字');
- }
- $sjId = $data['sjId'];
- $findShop = self::getByCondition(['sjId' => $sjId, 'shopName' => $shopName]);
- if (!empty($findShop) && $findShop['id'] != $id) {
- util::fail('门店名称已经存在');
- }
- $dist = $data['dist'] ?? '';
- $floor = $data['floor'] ?? '';
- $address = $data['address'] ?? '';
- $data['fullAddress'] = $data['city'] . $dist . $address . $floor;
- // 营业时间设置逻辑
- if ($data['openType'] == 0) { // openType: 0. 表示 24小时营业 1. 表示 xx ~ xx
- $data['openStartTime'] = ''; // openStartTime 营业开始时间,空表示24小时
- $data['openEndTime'] = '';
- }
- $respond = self::updateById($id, $data);
- $ptStyle = $shop['ptStyle'] ?? dict::getDict('ptStyle', 'hd');
- $default = $shop['default'] ?? 0;
- $sjName = $shop['merchantName'] ?? '';
- //默认门店只显示商家名称即可
- $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
- $shopUpdate = [
- 'name' => $name,
- 'mobile' => $data['mobile'] ?? '',
- 'province' => $data['province'] ?? '',
- 'city' => $data['city'] ?? '',
- 'dist' => $data['dist'] ?? '',
- 'address' => $data['address'] ?? '',
- 'floor' => $data['floor'] ?? '',
- 'fullAddress' => $data['fullAddress'] ?? '',
- 'showAddress' => $data['showAddress'] ?? '',
- 'lat' => $data['lat'] ?? '',
- 'long' => $data['long'] ?? '',
- ];
- $where = ['sjId' => $sjId, 'shopId' => $id];
- if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
- CustomClass::updateByCondition($where, $shopUpdate);
- } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- GhsClass::updateByCondition($where, $shopUpdate);
- }
- return $respond;
- }
- //取商家所有门店 ssh 2020.2.29
- public static function getAllShop($sjId)
- {
- return self::getAllByCondition(['sjId' => $sjId], null, "*");
- }
- //验证所属权限 ssh 2020.2.29
- public static function valid($shop, $sjId)
- {
- if (empty($shop)) {
- util::fail('门店无效');
- }
- if (isset($shop['sjId']) == false || $shop['sjId'] != $sjId) {
- util::fail('您没有权限访问');
- }
- }
- //删除门店 ssh 2020.3.1
- public static function deleteShop($shop)
- {
- if (isset($shop['default']) && $shop['default'] == 1) {
- util::fail('默认门店不允许删除');
- }
- $id = $shop['id'];
- self::updateById($id, ['delStatus' => 1]);
- }
- //生成收款码 ssh 2020.3.9
- public static function generateGatheringCode($sjId, $shopId)
- {
- $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account=" . $shopId;
- //强制转成https
- $url = httpUtil::becomeHttps($url);
- Yii::info('收款码url:' . $url);
- $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 16);
- Yii::info('gatheringCode:' . $gatheringCode);
- $imgUrl = Yii::$app->params['hdImgHost'] . 'gathering/1.jpg?x-oss-process=image/watermark,image_' . base64_encode($gatheringCode) . ',g_nw,x_276,y_463/watermark,image_' . base64_encode('gathering/logo_big.png?x-oss-process=image/resize,P_12') . ',g_nw,x_555,y_728';
- return $imgUrl;
- }
- //客户结帐增加余额 ssh 20210729
- public static function customClearAddBalance($main, $shop, $order)
- {
- $mainId = $shop->mainId ?? 0;
- $balance = bcadd($main->balance, $order->actPrice, 2);
- $txBalance = bcadd($main->txBalance, $order->actPrice, 2);
- $main->balance = $balance;
- $main->txBalance = $txBalance;
- $main->save();
- $clearId = $order->id ?? 0;
- $tx = dict::getDict('yeTx', 'can');
- $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
- $custom = '客户';
- if (isset($order->customName) && !empty($order->customName)) {
- $custom = $order->customName;
- }
- $change = [
- 'relateId' => $clearId,
- 'capitalType' => $capitalType,
- 'amount' => $order->actPrice,
- 'balance' => $balance,
- 'txBalance' => $txBalance,
- 'io' => 1,
- 'payWay' => $order->payWay,
- 'event' => $custom . "结帐(单号:{$order->orderSn})",
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'mainId' => $shop->mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- 'mainId' => $mainId,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::customClearAddBalance($shop, $order, $capitalType, $tx);
- }
- //客户使用优惠券增加余额 ssh 20210601
- public static function customKdUseCouponAddBalance($shop, $order, $capitalType)
- {
- //门店余额增加
- $amount = $order->discountAmount;
- $currentBalance = bcadd($shop->balance, $amount, 2);
- $shop->balance = $currentBalance;
- $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
- //可提现余额同步增加
- $currentTx = bcadd($shop->txBalance, $amount, 2);
- $shop->txBalance = $currentTx;
- $shop->save();
- //增加余额变动记录
- $id = $order->id;
- $event = "客户下单(使用平台优惠券{$amount}元)";
- $tx = dict::getDict('yeTx', 'can');
- $mainId = $shop->mainId ?? 0;
- $change = [
- 'relateId' => $id,
- 'capitalType' => $capitalType,
- 'amount' => $amount,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 1,
- 'payWay' => $order->payWay,
- 'event' => $event,
- 'mainId' => $mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::customKdUseCouponAddBalance($shop, $order, $capitalType, $tx);
- }
- //客户下单引起的余额增加 ssh 20210520
- public static function customKdAddBalance($main, $shop, $amount, $order, $capitalType)
- {
- //门店余额增加
- $mainId = $shop->mainId ?? 0;
- $currentBalance = bcadd($main->balance, $amount, 2);
- $main->balance = $currentBalance;
- //可提现余额同步增加
- $currentTx = bcadd($main->txBalance, $amount, 2);
- $main->txBalance = $currentTx;
- $main->save();
- $ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
- $customName = '客户';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $customId = $order->customId ?? 0;
- $custom = CustomClass::getById($customId, true);
- if (isset($custom->name) && !empty($custom->name)) {
- $customName = $custom->name;
- }
- }
- //增加余额变动记录
- $id = $order->id;
- $event = $customName . "下单" . floatval($amount) . "元";
- $tx = dict::getDict('yeTx', 'can');
- $fromType = $order->fromType ?? 1;
- $change = [
- 'relateId' => $id,
- 'capitalType' => $capitalType,
- 'amount' => $amount,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 1,
- 'payWay' => $order->payWay,
- 'event' => $event,
- 'mainId' => $mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- 'fromType' => $fromType,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
- }
- //门店充值增加余额 ssh 2021.2.21
- //$fix = true 余额只能在指定门店使用
- public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
- {
- $mainId = $shop->mainId ?? 0;
- $main = MainClass::getLockById($mainId);
- if (empty($main)) {
- util::fail('没有找到资产信息');
- }
- //门店余额增加
- $currentBalance = bcadd($main->balance, $amount, 2);
- $main->balance = $currentBalance;
- $currentTotalRecharge = bcadd($shop->totalRecharge, $amount, 2);
- $main->totalRecharge = $currentTotalRecharge;
- //定向消费余额
- if ($fix) {
- $currentFix = bcadd($main->fixBalance, $amount, 2);
- $main->fixBalance = $currentFix;
- }
- $currentTx = $main->txBalance;
- //提现余额
- if ($tx == dict::getDict('yeTx', 'can')) {
- $currentTx = bcadd($main->txBalance, $amount, 2);
- $main->txBalance = $currentTx;
- }
- $main->save();
- $order->totalRecharge = $currentTotalRecharge;
- $order->save();
- //增加余额变动记录
- $id = $order->id;
- $event = "充值{$amount}元";
- if ($order->shopAdminId == 0) {
- $event = "系统充值{$amount}元";
- }
- $change = [
- 'relateId' => $id,
- 'capitalType' => $capitalType,
- 'amount' => $amount,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 1,
- 'payWay' => $order->payWay,
- 'event' => $event,
- 'sjId' => $order->sjId,
- 'shopId' => $order->shopId,
- 'mainId' => $mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::rechargeAddBalance($shop, $amount, $order, $capitalType, $tx);
- }
- //采购余额付款,减少余额 ssh 20210519
- public static function purchaseReduceBalance($main, $shop, $amount, $order)
- {
- if (bccomp($amount, $main->balance, 2) == 1) {
- util::fail('余额不足');
- }
- $sjId = $order->sjId;
- $shopId = $order->shopId;
- $mainId = $order->mainId ?? 0;
- $currentBalance = bcsub($main->balance, $amount, 2);
- $main->balance = $currentBalance;
- $tx = dict::getDict('yeTx', 'canNot');
- //还有可提现余额也要先用掉
- $currentTxBalance = $main->txBalance;
- if ($currentTxBalance > 0) {
- $reduceTxBalance = $currentTxBalance > $amount ? $amount : $currentTxBalance;
- $main->txBalance = bcsub($currentTxBalance, $reduceTxBalance, 2);
- $tx = dict::getDict('yeTx', 'can');
- }
- $main->save();
- $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
- //增加余额变动记录
- $id = $order->id;
- $change = [
- 'relateId' => $id,
- 'capitalType' => $capitalType,
- 'amount' => $amount,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTxBalance,
- 'io' => 0,
- 'payWay' => $order->payWay,
- 'event' => "采购余额付款{$amount}元",
- 'sjId' => $sjId,
- 'shopId' => $shopId,
- 'mainId' => $mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::reduceBalance($shop, $amount, $order, $capitalType, $tx);
- }
- //零售采购退款
- public static function cgRefundAddBalance($main, $shop, $refundPrice, $cgRefund, $ghs)
- {
- //客户余额增加
- $currentBalance = bcadd($main->balance, $refundPrice, 2);
- $main->balance = $currentBalance;
- $main->save();
- $currentTxBalance = $main->txBalance;
- $currentType = dict::getDict('capitalType', 'cgRefund', 'id');
- $id = $cgRefund->id;
- $ptStyle = $shop->ptStyle;
- $sjId = $shop->sjId;
- $shopId = $shop->id;
- $mainId = $shop->mainId;
- $tx = dict::getDict('yeTx', 'canNot');
- $ghsName = $ghs->name ?? '';
- $change = [
- 'relateId' => $id,
- 'capitalType' => $currentType,
- 'amount' => $refundPrice,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTxBalance,
- 'io' => 1,
- 'payWay' => 0,
- 'event' => "采购退款({$ghsName})",
- 'sjId' => $sjId,
- 'shopId' => $shopId,
- 'mainId' => $mainId,
- 'tx' => $tx,
- 'ptStyle' => $ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- PtAssetClass::cgRefundAddBalance($shop, $refundPrice, $cgRefund, $currentType, $tx);
- }
- //供货商预订被多付了退款减少余额 ssh 20220324
- public static function ghsBookOrderRefundReduceBalance($main, $shop, $refund, $refundPrice)
- {
- $currentBalance = bcsub($main->balance, $refundPrice, 2);
- if ($currentBalance < 0) {
- util::fail('余额不足,请先充值');
- }
- $main->balance = $currentBalance;
- $currentTx = $main->txBalance;
- if ($currentTx > 0) {
- if ($refundPrice > $currentTx) {
- $currentTx = 0;
- } else {
- $currentTx = bcsub($currentTx, $refundPrice, 2);
- }
- }
- $main->txBalance = $currentTx;
- $main->save();
- $currentType = dict::getDict('capitalType', 'ghsBookRefund');
- $id = $refund->id;
- $event = "预订单被多付退给客户(退款单 {$refund->orderSn} 订单{$refund->relateOrderSn})";
- $relateOrderSn = $refund->relateOrderSn ?? '';
- if (!empty($relateOrderSn)) {
- $relateOrder = OrderClass::getByCondition(['orderSn' => $relateOrderSn], true);
- $customName = $relateOrder->customName ?? '';
- if (!empty($customName)) {
- $event = "预订单{$customName}多付退款(退款单 {$refund->orderSn} 订单{$refund->relateOrderSn})";
- }
- }
- $tx = dict::getDict('yeTx', 'can');
- $change = [
- 'relateId' => $id,
- 'capitalType' => $currentType,
- 'amount' => $refundPrice,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 0,
- 'payWay' => 0,
- 'event' => $event,
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'mainId' => $shop->mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::ghsBookOrderRefundReduceBalance($shop, $refund, $refundPrice);
- }
- //花店销售单退款减少余额
- public static function hdSaleRefundReduceBalance($main, $shop, $refund, $refundPrice)
- {
- //门店余额减少
- $currentBalance = bcsub($main->balance, $refundPrice, 2);
- if ($currentBalance < 0) {
- util::fail('余额不足,请先充值');
- }
- $main->balance = $currentBalance;
- $currentTx = $main->txBalance;
- if ($currentTx > 0) {
- if ($refundPrice > $currentTx) {
- $currentTx = 0;
- } else {
- $currentTx = bcsub($currentTx, $refundPrice, 2);
- }
- }
- $main->txBalance = $currentTx;
- $main->save();
- $currentType = dict::getDict('capitalType', 'hdOrderRefund');
- $id = $refund->id;
- $event = "退款给客户(退款单 {$refund->refundSn})";
- $relateOrderSn = $refund->orderSn ?? '';
- if (!empty($relateOrderSn)) {
- $relateOrder = OrderClass::getByCondition(['orderSn' => $relateOrderSn], true);
- $customName = $relateOrder->customName ?? '';
- if (!empty($customName)) {
- $event = "退款给{$customName}(退款单 {$refund->refundSn})";
- }
- }
- $tx = dict::getDict('yeTx', 'can');
- $change = [
- 'relateId' => $id,
- 'capitalType' => $currentType,
- 'amount' => $refundPrice,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 0,
- 'payWay' => 0,
- 'event' => $event,
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'mainId' => $shop->mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::hdSaleRefundReduceBalance($shop, $refund, $refundPrice);
- }
- //销售单退款减少余额 ssh 2021.2.21
- public static function saleRefundReduceBalance($main, $shop, $refund, $refundPrice)
- {
- //门店余额减少
- $currentBalance = bcsub($main->balance, $refundPrice, 2);
- if ($currentBalance < 0) {
- util::fail('余额不足,请先充值');
- }
- $main->balance = $currentBalance;
- $currentTx = $main->txBalance;
- if ($currentTx > 0) {
- if ($refundPrice > $currentTx) {
- $currentTx = 0;
- } else {
- $currentTx = bcsub($currentTx, $refundPrice, 2);
- }
- }
- $main->txBalance = $currentTx;
- $main->save();
- $currentType = dict::getDict('capitalType', 'saleRefund');
- $id = $refund->id;
- $event = "退款给客户(退款单 {$refund->orderSn})";
- $relateOrderSn = $refund->relateOrderSn ?? '';
- if (!empty($relateOrderSn)) {
- $relateOrder = OrderClass::getByCondition(['orderSn' => $relateOrderSn], true);
- $customName = $relateOrder->customName ?? '';
- if (!empty($customName)) {
- $event = "退款给{$customName}(退款单 {$refund->orderSn})";
- }
- }
- $tx = dict::getDict('yeTx', 'can');
- $change = [
- 'relateId' => $id,
- 'capitalType' => $currentType,
- 'amount' => $refundPrice,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 0,
- 'payWay' => 0,
- 'event' => $event,
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'mainId' => $shop->mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- PtAssetClass::saleRefundReduceBalance($shop, $refund, $refundPrice);
- }
- //获取商家所有的门店 ssh 2021.2.26
- public static function getSjShopList($sjId)
- {
- return self::getAllByCondition(['sjId' => $sjId, 'delStatus' => 0], null, ['id']);
- }
- //取门店长信息 ssh 2021.1.17
- public static function getSuper($id)
- {
- $shop = self::getById($id);
- if (empty($shop)) {
- return [];
- }
- $adminId = $shop['adminId'] ?? 0;
- return \bizHd\admin\classes\AdminClass::getDetail($adminId);
- }
- //佣金引起的余额增加 lqh 2021211
- /**
- * @param $shop
- * @param $amount 提现金额
- * @param $cashId 提现主键ID
- * @param $capitalType
- */
- public static function brokerageAddBalance($shop, $cash, $capitalType)
- {
- $amount = $cash->amount ?? 0;
- $amount = floatval($amount);
- $cashId = $cash->id ?? 0;
- $customerSjName = $cash->sjName ?? '';
- $customerName = $cash->shopName ?? '';
- //获取的佣金 万分之三 暂时先写死,后续可走配置
- $brokerage = bcmul($amount, 0.0003, 2);
- //门店余额增加
- $currentBalance = bcadd($shop->balance, $brokerage, 2);
- $shop->balance = $currentBalance;
- $shop->totalRecharge = bcadd($shop->totalRecharge, $brokerage, 2);
- //可提现余额同步增加
- $currentTx = bcadd($shop->txBalance, $brokerage, 2);
- $shop->txBalance = $currentTx;
- $shop->save();
- //增加余额变动记录
- $tx = dict::getDict('yeTx', 'can');
- $change = [
- 'relateId' => $cashId,
- 'capitalType' => $capitalType,
- 'amount' => $brokerage,
- 'balance' => $currentBalance,
- 'txBalance' => $currentTx,
- 'io' => 1,
- 'payWay' => 0,
- 'event' => $customerSjName . '-' . $customerName . "提现" . $amount . "元获得佣金",
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'mainId' => $shop->mainId,
- 'tx' => $tx,
- 'ptStyle' => $shop->ptStyle,
- ];
- ShopYeChangeClass::addChange($change, true);
- //平台余额增加
- $ptStyle = $shop->ptStyle;
- if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
- $asset = PtAssetClass::getHdBalance();
- } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $asset = PtAssetClass::getGhsBalance();
- } else {
- util::fail('没有找到平台');
- }
- //增加平台可余额
- $currentPtBalance = bcadd($asset->amount, $brokerage, 2);
- $asset->amount = $currentPtBalance;
- $asset->save();
- if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
- $txAsset = PtAssetClass::getHdTxBalance();
- } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $txAsset = PtAssetClass::getGhsTxBalance();
- } else {
- util::fail('没有找到平台');
- }
- //增加平台可提现余额
- $currentPtTxBalance = $txAsset->amount;
- $currentPtTxBalance = bcadd($currentPtTxBalance, $brokerage, 2);
- $txAsset->amount = $currentPtTxBalance;
- $txAsset->save();
- $change = [
- 'relateId' => $cashId,
- 'capitalType' => $capitalType,
- 'amount' => $brokerage,
- 'balance' => $currentPtBalance,
- 'txBalance' => $currentPtTxBalance,
- 'io' => 1,
- 'payWay' => 0,
- 'event' => $customerSjName . '-' . $customerName . "提现" . $amount . "元,代理商【{$shop->merchantName}-{$shop->shopName}】获得佣金",
- 'sjId' => $shop->sjId,
- 'shopId' => $shop->id,
- 'tx' => $tx,
- 'ptStyle' => $ptStyle,
- 'shopName' => $shop->shopName,
- 'sjName' => $shop->merchantName,
- ];
- PtYeChangeClass::addChange($change, true);
- }
- }
|