ShopClass.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <?php
  2. namespace biz\shop\classes;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\pt\classes\PtAssetClass;
  5. use biz\pt\classes\PtYeChangeClass;
  6. use biz\sj\classes\SjClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\order\classes\OrderClass;
  9. use bizGhs\product\classes\ProductClass;
  10. use common\components\dict;
  11. use common\components\httpUtil;
  12. use common\components\imgUtil;
  13. use common\components\qrCodeUtil;
  14. use common\components\stringUtil;
  15. use common\components\util;
  16. use Yii;
  17. use biz\base\classes\BaseClass;
  18. class ShopClass extends BaseClass
  19. {
  20. public static $baseFile = '\biz\shop\models\Shop';
  21. //获取图片信息 ssh 2021.3.14
  22. public static function getShopInfo($id)
  23. {
  24. $info = self::getById($id);
  25. if (empty($info)) {
  26. return $info;
  27. }
  28. $list = self::groupShopInfo([$info]);
  29. return current($list);
  30. }
  31. public static function getShopList($where)
  32. {
  33. $list = self::getList('*', $where, 'addTime DESC');
  34. return $list;
  35. }
  36. //查看店铺 ssh 2021.3.1
  37. public static function getShopByIds($ids)
  38. {
  39. $list = self::getByIds($ids);
  40. return self::groupShopInfo($list);
  41. }
  42. //门店 ssh 2021.3.1
  43. public static function groupShopInfo($list)
  44. {
  45. if (empty($list)) {
  46. return $list;
  47. }
  48. foreach ($list as $key => $val) {
  49. $list[$key]['avatar'] = imgUtil::groupImg($val['avatar']);
  50. }
  51. return $list;
  52. }
  53. //获取商家默认的门店ID ssh 2020.1.19
  54. public static function getDefaultShopId($merchant)
  55. {
  56. return isset($merchant['defaultShopId']) ? $merchant['defaultShopId'] : 0;
  57. }
  58. //创建门店 ssh 2020.2.8
  59. public static function addShop($data)
  60. {
  61. $data['createTime'] = date("Y-m-d H:i:s");
  62. $shopName = isset($data['shopName']) ? $data['shopName'] : '';
  63. if (empty($shopName)) {
  64. util::fail('请填写门店名称');
  65. }
  66. if (stringUtil::getWordNum($shopName) > 8) {
  67. util::fail('门店名称不能超过8个汉字,2个字母顶一个汉字');
  68. }
  69. $exists = self::getByCondition(['sjId' => $data['sjId'], 'shopName' => $shopName]);
  70. if (!empty($exists)) {
  71. util::fail('门店名称已经存在');
  72. }
  73. //补充fullAddress linqh 2021.4.18
  74. $data['fullAddress'] = $data['city'] . $data['address'] . $data['floor'];
  75. $img = '';
  76. if (isset($data['img']) && !empty($data['img'])) {
  77. $img = json_encode($data['img']);
  78. }
  79. $data['img'] = $img;
  80. if (isset($data['ptStyle']) == false) {
  81. util::fail('请先择平台类型');
  82. }
  83. $shop = self::add($data, true);
  84. $newShopId = $shop->id;
  85. $extData = [
  86. 'shopId' => $newShopId,
  87. ];
  88. ShopExtClass::add($extData);
  89. //初始化花材 linqh 2021.5.11
  90. $adminId = $data['adminId'] ?? 0;
  91. $shopId = $data['shopId'] ?? 0;
  92. ProductClass::newShopInitProduct($data['sjId'], $shopId, $newShopId, $adminId);
  93. return $shop;
  94. }
  95. //更新门店 ssh 2020.2.29
  96. public static function updateShop($shop, $data)
  97. {
  98. $id = $shop['id'] ?? 0;
  99. $shopName = isset($data['shopName']) ? $data['shopName'] : '';
  100. if (stringUtil::getWordNum($shopName) > 8) {
  101. util::fail('门店名称不能超过8个汉字,2个字母顶一个汉字');
  102. }
  103. $sjId = $data['sjId'];
  104. $findShop = self::getByCondition(['sjId' => $sjId, 'shopName' => $shopName]);
  105. if (!empty($findShop) && $findShop['id'] != $id) {
  106. util::fail('门店名称已经存在');
  107. }
  108. $dist = $data['dist'] ?? '';
  109. $floor = $data['floor'] ?? '';
  110. $address = $data['address'] ?? '';
  111. $data['fullAddress'] = $data['city'] . $dist . $address . $floor;
  112. $respond = self::updateById($id, $data);
  113. $ptStyle = $shop['ptStyle'] ?? dict::getDict('ptStyle', 'hd');
  114. $default = $shop['default'] ?? 0;
  115. $sjName = $shop['merchantName'] ?? '';
  116. //默认门店只显示商家名称即可
  117. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  118. $shopUpdate = [
  119. 'name' => $name,
  120. 'mobile' => $data['mobile'] ?? '',
  121. 'province' => $data['province'] ?? '',
  122. 'city' => $data['city'] ?? '',
  123. 'dist' => $data['dist'] ?? '',
  124. 'address' => $data['address'] ?? '',
  125. 'floor' => $data['floor'] ?? '',
  126. 'fullAddress' => $data['fullAddress'] ?? '',
  127. 'showAddress' => $data['showAddress'] ?? '',
  128. 'lat' => $data['lat'] ?? '',
  129. 'long' => $data['long'] ?? '',
  130. ];
  131. $where = ['sjId' => $sjId, 'shopId' => $id];
  132. if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
  133. CustomClass::updateByCondition($where, $shopUpdate);
  134. } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  135. GhsClass::updateByCondition($where, $shopUpdate);
  136. }
  137. return $respond;
  138. }
  139. //取商家所有门店 ssh 2020.2.29
  140. public static function getAllShop($sjId)
  141. {
  142. return self::getAllByCondition(['sjId' => $sjId], null, "*");
  143. }
  144. //验证所属权限 ssh 2020.2.29
  145. public static function valid($shop, $sjId)
  146. {
  147. if (empty($shop)) {
  148. util::fail('门店无效');
  149. }
  150. if (isset($shop['sjId']) == false || $shop['sjId'] != $sjId) {
  151. util::fail('您没有权限访问');
  152. }
  153. }
  154. //删除门店 ssh 2020.3.1
  155. public static function deleteShop($shop)
  156. {
  157. if (isset($shop['default']) && $shop['default'] == 1) {
  158. util::fail('默认门店不允许删除');
  159. }
  160. $id = $shop['id'];
  161. self::updateById($id, ['delStatus' => 1]);
  162. }
  163. //生成收款码 ssh 2020.3.9
  164. public static function generateGatheringCode($sjId, $shopId)
  165. {
  166. $url = Yii::$app->params['mallDomain'] . "/#/pages/pay/index?account=" . $shopId;
  167. //强制转成https
  168. $url = httpUtil::becomeHttps($url);
  169. Yii::info('收款码url:' . $url);
  170. $gatheringCode = qrCodeUtil::generateGatheringQrCode($url, $sjId, $shopId, '', 16);
  171. Yii::info('gatheringCode:' . $gatheringCode);
  172. $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';
  173. return $imgUrl;
  174. }
  175. //客户结帐增加余额 shish 20210729
  176. public static function customClearAddBalance($shop, $order)
  177. {
  178. $balance = bcadd($shop->balance, $order->actPrice, 2);
  179. $txBalance = bcadd($shop->txBalance, $order->actPrice, 2);
  180. $shop->balance = $balance;
  181. $shop->txBalance = $txBalance;
  182. $shop->save();
  183. $clearId = $order->id ?? 0;
  184. $tx = dict::getDict('yeTx', 'can');
  185. $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
  186. $custom = '客户';
  187. if (isset($order->customName) && !empty($order->customName)) {
  188. $custom = $order->customName;
  189. }
  190. $change = [
  191. 'relateId' => $clearId,
  192. 'capitalType' => $capitalType,
  193. 'amount' => $order->actPrice,
  194. 'balance' => $balance,
  195. 'txBalance' => $txBalance,
  196. 'io' => 1,
  197. 'payWay' => $order->payWay,
  198. 'event' => $custom . "结帐(单号:{$order->orderSn})",
  199. 'sjId' => $shop->sjId,
  200. 'shopId' => $shop->id,
  201. 'tx' => $tx,
  202. 'ptStyle' => $shop->ptStyle,
  203. ];
  204. ShopYeChangeClass::addChange($change, true);
  205. //平台余额增加
  206. PtAssetClass::customClearAddBalance($shop, $order, $capitalType, $tx);
  207. }
  208. //客户使用优惠券增加余额 shish 20210601
  209. public static function customKdUseCouponAddBalance($shop, $order, $capitalType)
  210. {
  211. //门店余额增加
  212. $amount = $order->discountAmount;
  213. $currentBalance = bcadd($shop->balance, $amount, 2);
  214. $shop->balance = $currentBalance;
  215. $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
  216. //可提现余额同步增加
  217. $currentTx = bcadd($shop->txBalance, $amount, 2);
  218. $shop->txBalance = $currentTx;
  219. $shop->save();
  220. //增加余额变动记录
  221. $id = $order->id;
  222. $event = "客户下单(使用平台优惠券{$amount}元)";
  223. $tx = dict::getDict('yeTx', 'can');
  224. $change = [
  225. 'relateId' => $id,
  226. 'capitalType' => $capitalType,
  227. 'amount' => $amount,
  228. 'balance' => $currentBalance,
  229. 'txBalance' => $currentTx,
  230. 'io' => 1,
  231. 'payWay' => $order->payWay,
  232. 'event' => $event,
  233. 'sjId' => $order->sjId,
  234. 'shopId' => $order->shopId,
  235. 'tx' => $tx,
  236. 'ptStyle' => $shop->ptStyle,
  237. ];
  238. ShopYeChangeClass::addChange($change, true);
  239. //平台余额增加
  240. PtAssetClass::customKdUseCouponAddBalance($shop, $order, $capitalType, $tx);
  241. }
  242. //客户下单引起的余额增加 shish 20210520
  243. public static function customKdAddBalance($shop, $amount, $order, $capitalType)
  244. {
  245. //门店余额增加
  246. $currentBalance = bcadd($shop->balance, $amount, 2);
  247. $shop->balance = $currentBalance;
  248. $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
  249. //可提现余额同步增加
  250. $currentTx = bcadd($shop->txBalance, $amount, 2);
  251. $shop->txBalance = $currentTx;
  252. $shop->save();
  253. $ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
  254. $customName = '客户';
  255. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  256. $customId = $order->customId ?? 0;
  257. $custom = CustomClass::getById($customId, true);
  258. if (isset($custom->name) && !empty($custom->name)) {
  259. $customName = $custom->name;
  260. }
  261. }
  262. //增加余额变动记录
  263. $id = $order->id;
  264. $event = $customName . "下单{$amount}元";
  265. $tx = dict::getDict('yeTx', 'can');
  266. $change = [
  267. 'relateId' => $id,
  268. 'capitalType' => $capitalType,
  269. 'amount' => $amount,
  270. 'balance' => $currentBalance,
  271. 'txBalance' => $currentTx,
  272. 'io' => 1,
  273. 'payWay' => $order->payWay,
  274. 'event' => $event,
  275. 'sjId' => $order->sjId,
  276. 'shopId' => $order->shopId,
  277. 'tx' => $tx,
  278. 'ptStyle' => $shop->ptStyle,
  279. ];
  280. ShopYeChangeClass::addChange($change, true);
  281. //平台余额增加
  282. PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
  283. }
  284. //门店充值增加余额 ssh 2021.2.21
  285. //$fix = true 余额只能在指定门店使用
  286. public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
  287. {
  288. //门店余额增加
  289. $currentBalance = bcadd($shop->balance, $amount, 2);
  290. $shop->balance = $currentBalance;
  291. $currentTotalRecharge = bcadd($shop->totalRecharge, $amount, 2);
  292. $shop->totalRecharge = $currentTotalRecharge;
  293. //定向消费余额
  294. if ($fix) {
  295. $currentFix = bcadd($shop->fixBalance, $amount, 2);
  296. $shop->fixBalance = $currentFix;
  297. }
  298. $currentTx = $shop->txBalance;
  299. //提现余额
  300. if ($tx == dict::getDict('yeTx', 'can')) {
  301. $currentTx = bcadd($shop->txBalance, $amount, 2);
  302. $shop->txBalance = $currentTx;
  303. }
  304. $shop->save();
  305. $order->totalRecharge = $currentTotalRecharge;
  306. $order->save();
  307. //增加余额变动记录
  308. $id = $order->id;
  309. $event = "充值{$amount}元";
  310. if ($order->shopAdminId == 0) {
  311. $event = "系统充值{$amount}元";
  312. }
  313. $change = [
  314. 'relateId' => $id,
  315. 'capitalType' => $capitalType,
  316. 'amount' => $amount,
  317. 'balance' => $currentBalance,
  318. 'txBalance' => $currentTx,
  319. 'io' => 1,
  320. 'payWay' => $order->payWay,
  321. 'event' => $event,
  322. 'sjId' => $order->sjId,
  323. 'shopId' => $order->shopId,
  324. 'tx' => $tx,
  325. 'ptStyle' => $shop->ptStyle,
  326. ];
  327. ShopYeChangeClass::addChange($change, true);
  328. //平台余额增加
  329. PtAssetClass::rechargeAddBalance($shop, $amount, $order, $capitalType, $tx);
  330. }
  331. //采购余额付款,减少余额 shish 20210519
  332. public static function purchaseReduceBalance($shop, $amount, $order)
  333. {
  334. if (bccomp($amount, $shop->balance, 2) == 1) {
  335. util::fail('余额不足');
  336. }
  337. $sjId = $order->sjId;
  338. $shopId = $order->shopId;
  339. $currentBalance = bcsub($shop->balance, $amount, 2);
  340. $shop->balance = $currentBalance;
  341. $tx = dict::getDict('yeTx', 'canNot');
  342. //还有可提现余额也要先用掉
  343. $currentTxBalance = $shop->txBalance;
  344. if ($currentTxBalance > 0) {
  345. $reduceTxBalance = $currentTxBalance > $amount ? $amount : $currentTxBalance;
  346. $shop->txBalance = bcsub($currentTxBalance, $reduceTxBalance, 2);
  347. $tx = dict::getDict('yeTx', 'can');
  348. }
  349. $shop->save();
  350. $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
  351. //增加余额变动记录
  352. $id = $order->id;
  353. $change = [
  354. 'relateId' => $id,
  355. 'capitalType' => $capitalType,
  356. 'amount' => $amount,
  357. 'balance' => $currentBalance,
  358. 'txBalance' => $currentTxBalance,
  359. 'io' => 0,
  360. 'payWay' => $order->payWay,
  361. 'event' => "采购余额付款{$amount}元",
  362. 'sjId' => $sjId,
  363. 'shopId' => $shopId,
  364. 'tx' => $tx,
  365. 'ptStyle' => $shop->ptStyle,
  366. ];
  367. ShopYeChangeClass::addChange($change, true);
  368. //平台余额增加
  369. PtAssetClass::reduceBalance($shop, $amount, $order, $capitalType, $tx);
  370. }
  371. //零售采购退款
  372. public static function cgRefundAddBalance($shop, $refundPrice, $cgRefund, $ghs)
  373. {
  374. //客户余额增加
  375. $currentBalance = bcadd($shop->balance, $refundPrice, 2);
  376. $shop->balance = $currentBalance;
  377. $shop->save();
  378. $currentTxBalance = $shop->txBalance;
  379. $currentType = dict::getDict('capitalType', 'cgRefund', 'id');
  380. $id = $cgRefund->id;
  381. $ptStyle = $shop->ptStyle;
  382. $sjId = $shop->sjId;
  383. $shopId = $shop->id;
  384. $tx = dict::getDict('yeTx', 'canNot');
  385. $ghsName = $ghs->name ?? '';
  386. $change = [
  387. 'relateId' => $id,
  388. 'capitalType' => $currentType,
  389. 'amount' => $refundPrice,
  390. 'balance' => $currentBalance,
  391. 'txBalance' => $currentTxBalance,
  392. 'io' => 1,
  393. 'payWay' => 0,
  394. 'event' => "采购退款({$ghsName})",
  395. 'sjId' => $sjId,
  396. 'shopId' => $shopId,
  397. 'tx' => $tx,
  398. 'ptStyle' => $ptStyle,
  399. ];
  400. ShopYeChangeClass::addChange($change, true);
  401. PtAssetClass::cgRefundAddBalance($shop, $refundPrice, $cgRefund, $currentType, $tx);
  402. }
  403. //销售单退款减少余额 ssh 2021.2.21
  404. public static function saleRefundReduceBalance($shop, $refund, $refundPrice)
  405. {
  406. //门店余额减少
  407. $currentBalance = bcsub($shop->balance, $refundPrice, 2);
  408. if ($currentBalance < 0) {
  409. util::fail('余额不足,请先充值');
  410. }
  411. $shop->balance = $currentBalance;
  412. $currentTx = $shop->txBalance;
  413. if ($currentTx > 0) {
  414. if ($refundPrice > $currentTx) {
  415. $currentTx = 0;
  416. } else {
  417. $currentTx = bcsub($currentTx, $refundPrice, 2);
  418. }
  419. }
  420. $shop->txBalance = $currentTx;
  421. $shop->save();
  422. $currentType = dict::getDict('capitalType', 'saleRefund');
  423. $id = $refund->id;
  424. $event = "退款给客户(退款单 {$refund->orderSn})";
  425. $relateOrderSn = $refund->relateOrderSn ?? '';
  426. if (!empty($relateOrderSn)) {
  427. $relateOrder = OrderClass::getByCondition(['orderSn' => $relateOrderSn], true);
  428. $customName = $relateOrder->customName ?? '';
  429. if (!empty($customName)) {
  430. $event = "退款给{$customName}(退款单 {$refund->orderSn})";
  431. }
  432. }
  433. $tx = dict::getDict('yeTx', 'can');
  434. $change = [
  435. 'relateId' => $id,
  436. 'capitalType' => $currentType,
  437. 'amount' => $refundPrice,
  438. 'balance' => $currentBalance,
  439. 'txBalance' => $currentTx,
  440. 'io' => 0,
  441. 'payWay' => 0,
  442. 'event' => $event,
  443. 'sjId' => $shop->sjId,
  444. 'shopId' => $shop->id,
  445. 'tx' => $tx,
  446. 'ptStyle' => $shop->ptStyle,
  447. ];
  448. ShopYeChangeClass::addChange($change, true);
  449. //平台余额增加
  450. PtAssetClass::saleRefundReduceBalance($shop, $refund, $refundPrice);
  451. }
  452. //获取商家所有的门店 ssh 2021.2.26
  453. public static function getSjShopList($sjId)
  454. {
  455. return self::getAllByCondition(['sjId' => $sjId, 'delStatus' => 0], null, ['id']);
  456. }
  457. //取门店长信息 ssh 2021.1.17
  458. public static function getSuper($id)
  459. {
  460. $shop = self::getById($id);
  461. if (empty($shop)) {
  462. return [];
  463. }
  464. $adminId = $shop['adminId'] ?? 0;
  465. return \bizHd\admin\classes\AdminClass::getDetail($adminId);
  466. }
  467. //佣金引起的余额增加 lqh 2021211
  468. /**
  469. * @param $shop
  470. * @param $amount 提现金额
  471. * @param $cashId 提现主键ID
  472. * @param $capitalType
  473. */
  474. public static function brokerageAddBalance($shop, $cash, $capitalType)
  475. {
  476. $amount = $cash->amount ?? 0;
  477. $amount = floatval($amount);
  478. $cashId = $cash->id ?? 0;
  479. $customerSjName = $cash->sjName ?? '';
  480. $customerName = $cash->shopName ?? '';
  481. //获取的佣金 万分之三 暂时先写死,后续可走配置
  482. $brokerage = bcmul($amount, 0.0003, 2);
  483. //门店余额增加
  484. $currentBalance = bcadd($shop->balance, $brokerage, 2);
  485. $shop->balance = $currentBalance;
  486. $shop->totalRecharge = bcadd($shop->totalRecharge, $brokerage, 2);
  487. //可提现余额同步增加
  488. $currentTx = bcadd($shop->txBalance, $brokerage, 2);
  489. $shop->txBalance = $currentTx;
  490. $shop->save();
  491. //增加余额变动记录
  492. $tx = dict::getDict('yeTx', 'can');
  493. $change = [
  494. 'relateId' => $cashId,
  495. 'capitalType' => $capitalType,
  496. 'amount' => $brokerage,
  497. 'balance' => $currentBalance,
  498. 'txBalance' => $currentTx,
  499. 'io' => 1,
  500. 'payWay' => 0,
  501. 'event' => $customerSjName . '-' . $customerName . "提现" . $amount . "元获得佣金",
  502. 'sjId' => $shop->sjId,
  503. 'shopId' => $shop->id,
  504. 'tx' => $tx,
  505. 'ptStyle' => $shop->ptStyle,
  506. ];
  507. ShopYeChangeClass::addChange($change, true);
  508. //平台余额增加
  509. $ptStyle = $shop->ptStyle;
  510. if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
  511. $asset = PtAssetClass::getHdBalance();
  512. } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  513. $asset = PtAssetClass::getGhsBalance();
  514. } else {
  515. util::fail('没有找到平台');
  516. }
  517. //增加平台可余额
  518. $currentPtBalance = bcadd($asset->amount, $brokerage, 2);
  519. $asset->amount = $currentPtBalance;
  520. $asset->save();
  521. if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
  522. $txAsset = PtAssetClass::getHdTxBalance();
  523. } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  524. $txAsset = PtAssetClass::getGhsTxBalance();
  525. } else {
  526. util::fail('没有找到平台');
  527. }
  528. //增加平台可提现余额
  529. $currentPtTxBalance = $txAsset->amount;
  530. $currentPtTxBalance = bcadd($currentPtTxBalance, $brokerage, 2);
  531. $txAsset->amount = $currentPtTxBalance;
  532. $txAsset->save();
  533. $change = [
  534. 'relateId' => $cashId,
  535. 'capitalType' => $capitalType,
  536. 'amount' => $brokerage,
  537. 'balance' => $currentPtBalance,
  538. 'txBalance' => $currentPtTxBalance,
  539. 'io' => 1,
  540. 'payWay' => 0,
  541. 'event' => $customerSjName . '-' . $customerName . "提现" . $amount . "元,代理商【{$shop->merchantName}-{$shop->shopName}】获得佣金",
  542. 'sjId' => $shop->sjId,
  543. 'shopId' => $shop->id,
  544. 'tx' => $tx,
  545. 'ptStyle' => $ptStyle,
  546. 'shopName' => $shop->shopName,
  547. 'sjName' => $shop->merchantName,
  548. ];
  549. PtYeChangeClass::addChange($change, true);
  550. }
  551. }