ShareController.php 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use app\constants\OptionSetting;
  9. use app\jobs\LgCashJob;
  10. use app\models\Cash;
  11. use app\models\CashExt;
  12. use app\models\Color;
  13. use app\models\Lg;
  14. use app\models\Option;
  15. use app\models\OrderDetail;
  16. use app\models\Qrcode;
  17. use app\models\Share;
  18. use app\models\ShareGroupPurchaseUser;
  19. use app\models\Shop;
  20. use app\models\ShopShare;
  21. use app\models\TeamGrades;
  22. use app\models\User;
  23. use app\models\UserShareMoney;
  24. use app\models\WechatConfig;
  25. use app\modules\admin\models\CashForm;
  26. use app\modules\admin\models\CashListForm;
  27. use app\modules\admin\models\QrcodeForm;
  28. use app\modules\admin\models\ShareListForm;
  29. use app\modules\admin\models\ShareOrderForm;
  30. use app\modules\admin\models\ShareSettingForm;
  31. use app\utils\Alipay\Alipay;
  32. use app\utils\LgApi;
  33. use app\utils\Notice\NoticeSend;
  34. use yii\helpers\Json;
  35. use app\models\SaasUser;
  36. use app\models\AccountLog;
  37. use app\models\Store;
  38. use app\models\StoreMoneyLog;
  39. use app\modules\admin\models\RechargeForm;
  40. use app\modules\client\models\v1\RcCommissionForm;
  41. class ShareController extends BaseController
  42. {
  43. /**
  44. * @return string
  45. * 分销商列表
  46. */
  47. public function actionList()
  48. {
  49. $store_id = get_store_id();
  50. $form = new ShareListForm();
  51. $form->attributes = get_params();
  52. $form->store_id = $store_id;
  53. return $this->asJson($form->getList());
  54. }
  55. /**
  56. * 设置分销商等级
  57. */
  58. public function actionSetShareLevel()
  59. {
  60. $store_id = get_store_id();
  61. $form = new ShareListForm();
  62. $form->attributes = post_params();
  63. $form->store_id = $store_id;
  64. return $this->asJson($form->setShareLevel());
  65. }
  66. /**
  67. * @return mixed|string
  68. * 佣金设置
  69. */
  70. public function actionBasicSetting()
  71. {
  72. $store_id = get_store_id();
  73. $shareOption = Option::findOne([
  74. 'store_id' => $store_id, 'group' => OptionSetting::SHARE_GROUP_NAME,
  75. 'name' => OptionSetting::SHARE_BASIC_SETTING
  76. ]);
  77. if (!$shareOption) {
  78. $shareOption = new Option();
  79. }
  80. $form = new ShareSettingForm();
  81. $form->data = post_params();
  82. $form->model = $shareOption;
  83. $form->store_id = get_store_id();
  84. return $this->asJson($form->setBasicSetting());
  85. }
  86. /**
  87. * @return mixed|string
  88. * 佣金设置
  89. */
  90. public function actionSaasBasicSetting()
  91. {
  92. $store_id = -1;
  93. $shareOption = Option::findOne([
  94. 'store_id' => $store_id, 'group' => OptionSetting::SHARE_GROUP_NAME,
  95. 'name' => OptionSetting::SHARE_BASIC_SETTING
  96. ]);
  97. if (!$shareOption) {
  98. $shareOption = new Option();
  99. }
  100. $form = new ShareSettingForm();
  101. $form->data = post_params();
  102. $form->model = $shareOption;
  103. $form->store_id = $store_id;
  104. return $this->asJson($form->setSaasBasicSetting());
  105. }
  106. /**
  107. * @return mixed|string
  108. * 佣金设置
  109. */
  110. public function actionMoneySetting()
  111. {
  112. $first_name = post_params('first_name');
  113. if (empty($first_name)) {
  114. $first_name = '一级';
  115. }
  116. $second_name = post_params('second_name');
  117. if (empty($second_name)) {
  118. $second_name = '二级';
  119. }
  120. $third_name = post_params('third_name');
  121. if (empty($third_name)) {
  122. $third_name = '三级';
  123. }
  124. $expire_day = !empty(post_params('expire_day')) ? post_params('expire_day') : 0;
  125. $scale = !empty(post_params('scale')) ? post_params('scale') : 0;
  126. // 佣金类型:1.会员佣金,2.订单佣金
  127. $commission_type = !empty(post_params('commission_type')) ? post_params('commission_type') : '';
  128. // 佣金发放类型:0.佣金,1.积分,2.余额
  129. $giveType = !empty(post_params('giveType')) ? post_params('giveType') : '';
  130. $value = [
  131. 'level_one' => [
  132. 'text' => $first_name,
  133. 'value' => post_params('first'),
  134. ],
  135. 'level_two' => [
  136. 'text' => $second_name,
  137. 'value' => post_params('second'),
  138. ],
  139. 'level_three' => [
  140. 'text' => $third_name,
  141. 'value' => post_params('third'),
  142. ],
  143. 'commission_type' => $commission_type,
  144. 'giveType' => $giveType,
  145. 'expire_day' => $expire_day,
  146. 'scale' => $scale,
  147. ];
  148. if (
  149. !is_numeric(post_params('first')) || !is_numeric(post_params('second')) ||
  150. !is_numeric(post_params('third'))
  151. ) {
  152. return $this->asJson(['code' => 1, 'msg' => '佣金请输入数字!']);
  153. }
  154. $store_id = get_store_id();
  155. $shareOption = Option::findOne([
  156. 'store_id' => $store_id, 'group' => OptionSetting::SHARE_GROUP_NAME,
  157. 'name' => OptionSetting::SHARE_MONEY_SETTING
  158. ]);
  159. if (!$shareOption) {
  160. $shareOption = new Option();
  161. }
  162. $form = new ShareSettingForm();
  163. $form->data = $value;
  164. $form->model = $shareOption;
  165. $form->store_id = $store_id;
  166. return $this->asJson($form->setMoneySetting());
  167. }
  168. /**
  169. * 分销商详情
  170. */
  171. public function actionDetail()
  172. {
  173. $form = new ShareOrderForm();
  174. $form->attributes = post_params();
  175. $form->store_id = get_store_id();
  176. return $this->asJson($form->detail());
  177. }
  178. /**
  179. * 分销商订单
  180. */
  181. public function actionShareOrder()
  182. {
  183. $form = new ShareOrderForm();
  184. $form->attributes = get_params();
  185. $form->store_id = get_store_id();
  186. return $this->asJson($form->shareOrder());
  187. }
  188. /**
  189. * @return mixed|string
  190. * 佣金设置获取
  191. */
  192. public function actionGetShareSetting()
  193. {
  194. $form = new ShareSettingForm();
  195. $form->name = get_params('name');
  196. $form->store_id = get_store_id();
  197. return $this->asJson($form->getShareSetting());
  198. }
  199. /**
  200. * @return mixed|string
  201. * saas佣金设置获取
  202. */
  203. public function actionGetSaasShareSetting()
  204. {
  205. $form = new ShareSettingForm();
  206. $form->name = get_params('name');
  207. $form->store_id = -1;
  208. return $this->asJson($form->getShareSetting());
  209. }
  210. /**
  211. * 添加备注
  212. * @return array
  213. */
  214. public function actionSellerComments()
  215. {
  216. $id = post_params('id');
  217. $seller_comments = post_params('seller_comments');
  218. $share = Share::findOne([
  219. 'store_id' => get_store_id(), 'is_delete' => Share::SHARE_NOT_DELETE,
  220. 'id' => $id
  221. ]);
  222. $share->seller_comments = $seller_comments;
  223. if ($share->save()) {
  224. return $this->asJson([
  225. 'code' => 0,
  226. 'msg' => '保存成功'
  227. ]);
  228. } else {
  229. $this->asJson(['code' => 1, 'msg' => '保存异常']);
  230. }
  231. }
  232. /**
  233. * @param int $id
  234. * @param int $status
  235. * @return mixed|string
  236. * @DateTime 2021-12-09
  237. * 申请审核
  238. */
  239. public function actionStatus()
  240. {
  241. $id = post_params('id');
  242. $status = intval(post_params('status'));
  243. $store_id = get_store_id();
  244. if (is_array($id)) {
  245. $share = Share::find()->where(['in','id',$id, 'is_delete' => Share::SHARE_NOT_DELETE, 'store_id' => $store_id])->asArray()->all();
  246. } else {
  247. $share = Share::findOne(['id' => $id, 'is_delete' => Share::SHARE_NOT_DELETE, 'store_id' => $store_id]);
  248. }
  249. if (!$share) {
  250. return $this->asJson([
  251. 'code' => 1,
  252. 'msg' => '网络异常,请刷新重试'
  253. ]);
  254. }
  255. if (!in_array($status, [1, 2])) {
  256. return $this->asJson([
  257. 'code' => 1,
  258. 'msg' => '网络异常,请刷新重试'
  259. ]);
  260. }
  261. if ($status == 1) {
  262. if (is_array($share)) {
  263. $shares = SHare::updateAll(['status' => $status, 'created_at' => time()], ['in', 'id', $id]);
  264. foreach ($share as &$val) {
  265. User::updateAll(['time' => time(), 'is_distributor' => User::IS_DISTRIBUTOR], ['id' => $val['user_id'],'store_id' => $store_id]);
  266. NoticeSend::ShareExamine($val['user_id'], $val['mobile'], '通过', '分销商');
  267. }
  268. } else {
  269. $shares = SHare::updateAll(['status' => $status, 'created_at' => time()], ['=', 'id', $id]);
  270. User::updateAll(['time' => time(), 'is_distributor' => User::IS_DISTRIBUTOR], ['id' => $share->user_id,'store_id' => $store_id]);
  271. NoticeSend::ShareExamine($share->user_id, $share->mobile, '通过', '分销商');
  272. }
  273. } else {
  274. if (is_array($share)) {
  275. $shares = SHare::updateAll(['status' => $status, 'created_at' => time()], ['in', 'id', $id]);
  276. foreach ($share as &$val) {
  277. User::updateAll(['time' => time(), 'is_distributor' => User::NOT_DISTRIBUTOR], ['id' => $val['user_id'],'store_id' => $store_id]);
  278. NoticeSend::ShareExamine($val['user_id'], $val['mobile'], '不通过', '分销商');
  279. }
  280. } else {
  281. $shares = SHare::updateAll(['status' => $status, 'created_at' => time()], ['=', 'id', $id]);
  282. User::updateAll(['time' => time(), 'is_distributor' => User::NOT_DISTRIBUTOR], [
  283. 'id' => $share->user_id,
  284. 'store_id' => $store_id
  285. ]);
  286. NoticeSend::ShareExamine($share->user_id, $share->mobile, '不通过', '分销商');
  287. }
  288. }
  289. if ($shares > 0 ) {
  290. return $this->asJson([
  291. 'code' => 0,
  292. 'msg' => '成功'
  293. ]);
  294. } else {
  295. return $this->asJson([
  296. 'code' => 1,
  297. 'msg' => '请刷新重试'
  298. ]);
  299. }
  300. }
  301. /**
  302. * @param int $id
  303. * @return mixed|string
  304. * @throws \yii\db\Exception
  305. * 删除分销商
  306. */
  307. public function actionDel()
  308. {
  309. $id = post_params('id');
  310. $share = Share::findOne(['id' => $id, 'is_delete' => Share::SHARE_NOT_DELETE]);
  311. if (!$share) {
  312. return $this->asJson([
  313. 'code' => 1,
  314. 'msg' => '网络异常'
  315. ]);
  316. }
  317. $t = \Yii::$app->db->beginTransaction();
  318. $count1 = Share::updateAll(['is_delete' => Share::SHARE_IS_DELETE], 'id=:id', [':id' => $id]);
  319. $user = User::findOne($share->user_id);
  320. $user->is_distributor = User::NOT_DISTRIBUTOR;
  321. // $user->parent_id = 0;
  322. // $user->old_parent_id = 0;
  323. $user->time = time();
  324. $user->save();
  325. // User::updateAll(['parent_id' => 0], 'parent_id=:parent_id', [':parent_id' => $share->user_id]);
  326. if ($count1 != 0) {
  327. $t->commit();
  328. return $this->asJson([
  329. 'code' => 0,
  330. 'msg' => '成功'
  331. ]);
  332. } else {
  333. $t->rollBack();
  334. return $this->asJson([
  335. 'code' => 1,
  336. 'msg' => '网络异常'
  337. ]);
  338. }
  339. }
  340. /**
  341. * 分销提现列表
  342. * @return \yii\web\Response
  343. */
  344. public function actionCash()
  345. {
  346. $store_id = get_store_id();
  347. $form = new CashForm();
  348. $form->attributes = all_params();
  349. $form->store_id = $store_id;
  350. if(get_mch_id()){
  351. $form->mch = 1;
  352. $form->mch_id = get_mch_id();
  353. $form->cash_type = Cash::IS_CASH_TYPE_MCH;
  354. }
  355. return $this->asJson($form->getShareCashList());
  356. }
  357. /**
  358. * 用户分销提现列表
  359. */
  360. public function actionUserCash()
  361. {
  362. $store_id = get_store_id();
  363. $form = new CashForm();
  364. $form->attributes = get_params();
  365. $form->store_id = $store_id;
  366. return $this->asJson($form->shareCashUserList());
  367. }
  368. /**
  369. * 用户分销提现列表
  370. */
  371. public function actionSaasCash()
  372. {
  373. $store_id = -1; //saascash store_id 固定为-1
  374. $form = new CashForm();
  375. $form->attributes = get_params();
  376. $form->store_id = $store_id;
  377. return $this->asJson($form->shareCashSaasList());
  378. }
  379. /**
  380. * 修改分销商备注
  381. */
  382. public function actionSetShareSeller()
  383. {
  384. $id = post_params('id');
  385. $seller_comments = post_params('seller_comments');
  386. $share = Share::findOne(['id' => (int)$id]);
  387. if (!$share) {
  388. return $this->asJson([
  389. 'code' => 1,
  390. 'msg' => '分销商不存在'
  391. ]);
  392. }
  393. $share->seller_comments = $seller_comments;
  394. if ($share->save()) {
  395. return $this->asJson([
  396. 'code' => 0,
  397. 'msg' => '保存成功'
  398. ]);
  399. }
  400. }
  401. /**
  402. * 提现申请审核
  403. * @return \yii\web\Response
  404. */
  405. public function actionApply()
  406. {
  407. $id = post_params('id');
  408. $status = post_params('status');
  409. $store_id = get_store_id();
  410. $cash = Cash::findOne([
  411. 'id' => $id, 'is_delete' => Cash::IS_DELETE_NO,
  412. 'store_id' => $store_id
  413. ]);
  414. if (!$cash) {
  415. return $this->asJson([
  416. 'code' => 1,
  417. 'msg' => '提现记录不存在,请刷新重试'
  418. ]);
  419. }
  420. if (!$cash->order_no) {
  421. $order_no = null;
  422. while (true) {
  423. $order_no = date('YmdHis') . mt_rand(100000, 999999);
  424. $exist_order_no = Cash::find()->where(['order_no' => $order_no])->exists();
  425. if (!$exist_order_no) {
  426. break;
  427. }
  428. }
  429. $cash->order_no = $order_no;
  430. $cash->save();
  431. }
  432. \Yii::$app->cache->set('cash_cache_' . $id, $cash->order_no);
  433. if (!in_array($status, [1, 3])) {
  434. \Yii::$app->cache->set('cash_cache_' . $id, false);
  435. return $this->asJson([
  436. 'code' => 1,
  437. 'msg' => '提现记录已审核,请刷新重试'
  438. ]);
  439. }
  440. $cash->status = $status;
  441. if ($status == Cash::STATUS_REFUSE) {
  442. $user = User::findOne(['id' => $cash->user_id]);
  443. // if (! $user) {
  444. // return $this->asJson([
  445. // 'code' => 1,
  446. // 'msg' => '用户数据不存在'
  447. // ]);
  448. // }
  449. cash::cashRefuse($cash->id);
  450. NoticeSend::CashFail($cash->user_id, $user->binding, $cash->price, '提现被驳回', '提现被驳回');
  451. }
  452. if ($cash->save()) {
  453. return $this->asJson([
  454. 'code' => 0,
  455. 'msg' => '成功'
  456. ]);
  457. } else {
  458. return $this->asJson([
  459. 'code' => 1,
  460. 'msg' => '网络异常,请刷新重试'
  461. ]);
  462. }
  463. }
  464. /**
  465. * 商盟saas提现申请审核
  466. * @return \yii\web\Response
  467. */
  468. public function actionSaasApply()
  469. {
  470. $id = post_params('id');
  471. $status = post_params('status');
  472. $store_id = -1; //saas 商盟店铺固定id为-1
  473. $cash = Cash::findOne([
  474. 'id' => $id, 'is_delete' => Cash::IS_DELETE_NO,
  475. 'store_id' => $store_id
  476. ]);
  477. if (!$cash) {
  478. return $this->asJson([
  479. 'code' => 1,
  480. 'msg' => '提现记录不存在,请刷新重试'
  481. ]);
  482. }
  483. if (!$cash->order_no) {
  484. $order_no = null;
  485. while (true) {
  486. $order_no = date('YmdHis') . mt_rand(100000, 999999);
  487. $exist_order_no = Cash::find()->where(['order_no' => $order_no])->exists();
  488. if (!$exist_order_no) {
  489. break;
  490. }
  491. }
  492. $cash->order_no = $order_no;
  493. $cash->save();
  494. }
  495. \Yii::$app->cache->set('cash_cache_' . $id, $cash->order_no);
  496. if (!in_array($status, [1, 3])) {
  497. \Yii::$app->cache->set('cash_cache_' . $id, false);
  498. return $this->asJson([
  499. 'code' => 1,
  500. 'msg' => '提现记录已审核,请刷新重试'
  501. ]);
  502. }
  503. $cash->status = $status;
  504. if ($status == Cash::STATUS_REFUSE) {
  505. $saas = SaasUser::findOne(['id' => $cash->saas_id]);
  506. if (! $saas) {
  507. return $this->asJson([
  508. 'code' => 1,
  509. 'msg' => '用户数据不存在'
  510. ]);
  511. }
  512. if ($cash->cash_type == 0) {
  513. $saas->price += $cash->price;
  514. if (!$saas->save()) {
  515. return $this->asJson([
  516. 'code' => 1,
  517. 'msg' => '网络异常'
  518. ]);
  519. }
  520. }
  521. // else {
  522. // $user->tuan_price += $cash->price;
  523. // if (!$user->save()) {
  524. // return $this->asJson([
  525. // 'code' => 1,
  526. // 'msg' => '网络异常'
  527. // ]);
  528. // } else {
  529. // $shop = Shop::findOne(['user_id'=> $user->id, 'store_id' => $user->store_id, 'is_delete' => 0,'shop_audit' => 1]);
  530. // $shop_form = new ShopShare();
  531. // $shop_form->store_id = $user->store_id;
  532. // $shop_form->shop_id = $shop->id;
  533. // $shop_form->type = 0;
  534. // $shop_form->amount = $cash->price;
  535. // $shop_form->the_desc = '团长'.$user->nickname.'提现驳回';
  536. // $shop_form->created_at = time();
  537. // $shop_form->status = 1;
  538. // $shop_form->save();
  539. // }
  540. // }
  541. //NoticeSend::CashFail($cash->user_id, $user->binding, $cash->price, '提现被驳回', '提现被驳回');
  542. }
  543. if ($cash->save()) {
  544. return $this->asJson([
  545. 'code' => 0,
  546. 'msg' => '成功'
  547. ]);
  548. } else {
  549. return $this->asJson([
  550. 'code' => 1,
  551. 'msg' => '网络异常,请刷新重试'
  552. ]);
  553. }
  554. }
  555. public function actionConfirm()
  556. {
  557. $id = post_params('id');
  558. $status = post_params('status');
  559. $store_id = get_store_id();
  560. $store = Store::findOne($store_id);
  561. $cash = Cash::findOne([
  562. 'id' => $id,
  563. 'is_delete' => Cash::IS_DELETE_NO,
  564. 'store_id' => $store_id
  565. ]);
  566. if (!$cash) {
  567. return $this->asJson([
  568. 'code' => 1,
  569. 'msg' => '提现记录不存在,请刷新重试'
  570. ]);
  571. }
  572. if ($status == Cash::STATUS_GIVEN) {
  573. if($store->is_platform_transfers == 1){
  574. $store_wechat_cash = json_decode(Option::get('store_wechat_cash', $store_id, 'store')['value'], true);
  575. $val = 0;
  576. foreach ((array)$store_wechat_cash as $value) {
  577. if (!empty($value)) {
  578. $val = 1;
  579. break;
  580. }
  581. }
  582. if(!$val){
  583. return $this->asJson([
  584. 'code' => 1,
  585. 'msg' => '未配置平台微信提现设置'
  586. ]);
  587. }
  588. }
  589. }
  590. if (!$cash->order_no) {
  591. $order_no = null;
  592. while (true) {
  593. $order_no = date('YmdHis') . mt_rand(100000, 999999);
  594. $exist_order_no = Cash::find()->where(['order_no' => $order_no])->exists();
  595. if (!$exist_order_no) {
  596. break;
  597. }
  598. }
  599. $cash->order_no = $order_no;
  600. $cash->save();
  601. }
  602. if ($cash->status != 1) {
  603. return $this->asJson([
  604. 'code' => 1,
  605. 'msg' => '操作错误,请刷新重试'
  606. ]);
  607. }
  608. $res = [];
  609. $cashExt = CashExt::findOne(['cash_id' => $cash['id'], 'cash_price_type' => CashExt::CASH_PRICE_TYPE_AMOUNT]);
  610. if ($cashExt) {
  611. $price = $cashExt->real_price;
  612. } else {
  613. $price = Cash::getServiceMoney($cash);
  614. }
  615. $servePrice = $cash->price * ($cash->service_charge / 100);
  616. if ($store->store_balance < $price && $store->is_platform_transfers == 1) {
  617. return $this->asJson([
  618. 'code' => 1,
  619. 'msg' => '店铺剩余提现余额不足'
  620. ]);
  621. }
  622. $wechat_type = 1;
  623. $wechat_cash = Option::get('wechat_cash', $store_id, 'store')['value'];
  624. if($store->is_platform_transfers == 1){
  625. $wechat_cash = Option::get('store_wechat_cash', $store_id, 'store')['value'];
  626. $wechat_type = 0;
  627. }
  628. $t = \Yii::$app->db->beginTransaction();
  629. if ($status == Cash::STATUS_GIVEN) { //微信自动打款
  630. $cash->status = Cash::STATUS_GIVEN;
  631. $cash->pay_time = time();
  632. $cash->pay_type = Cash::PAY_TYPE_WX;
  633. $cash->wx_cash_status = -1;
  634. $user = User::findOne(['id' => $cash->user_id]);
  635. $data = [
  636. 'partner_trade_no' => $cash->order_no,
  637. 'openid' => $user->wechat_open_id,
  638. 'check_name' => 'NO_CHECK',
  639. 'amount' => $price * 100,
  640. 'desc' => '转账',
  641. 'user_name' => $cash->name
  642. ];
  643. if ((int)$cash->type === 0) {
  644. if (\Yii::$app->prod_is_dandianpu() && !\app\models\Store::hasIncoming($store_id)) {
  645. //商城是否进件
  646. //商城余额是否充足
  647. $storeMoney = \app\models\StoreCash::getMaxCash($store);
  648. if($storeMoney < $price){
  649. $t->rollBack();
  650. return $this->asJson([
  651. 'code' => 1,
  652. 'msg' => '操作错误,商城余额不足! 当前余额:¥' . $storeMoney
  653. ]);
  654. }
  655. //扣除商城余额
  656. $subMoney = \app\models\Store::subMoney($store, $price);
  657. if(!$subMoney){
  658. $t->rollBack();
  659. return $this->asJson([
  660. 'code' => 1,
  661. 'msg' => '网络异常,subMoney失败1',
  662. ]);
  663. }
  664. } else {
  665. if (\Yii::$app->prod_is_duli()) {
  666. // $WechatConfig = WechatConfig::findOne(['store_id' => get_store_id()]);
  667. // if (empty($WechatConfig->mch_id) || empty($WechatConfig->pay_key) || empty($WechatConfig->app_id)|| empty($WechatConfig->cert_pem)|| empty($WechatConfig->key_pem)) {
  668. // return $this->asJson([
  669. // 'code' => 1,
  670. // 'msg' => "后台参数配置错误,请检查参数后重试"
  671. // ]);
  672. // }
  673. }
  674. }
  675. if ($wechat_type == 0) {
  676. $cashExt = CashExt::findOne(['cash_id' => $cash->id, 'cash_price_type' => CashExt::CASH_PRICE_TYPE_AMOUNT]);
  677. $before = $store->store_balance;
  678. $store->store_balance -= $cashExt ? $cashExt->real_price : $price;
  679. $store->price -= $cashExt ? $cashExt->real_price : $price;
  680. $store->store_withdrawn_cash += $cashExt ? $cashExt->real_price : $price;
  681. $after = $store->store_balance;
  682. $cashExtServePrice = $cashExt ? bcsub($cashExt->price, $cashExt->real_price, 2) : $servePrice;
  683. $cashExtPrice = $cashExt ? $cashExt->price : $cash->price;
  684. $cashExtRealPrice = $cashExt ? $cashExt->real_price : $price;
  685. if ($store->save()) {
  686. StoreMoneyLog::saveLog(get_store_id(), StoreMoneyLog::LOG_TYPE_EXPEND, StoreMoneyLog::TYPE_SHARE, $cashExtRealPrice, " ID{$id}:用户提现{$cashExtPrice}元,扣除手续费{$cashExtServePrice}元,提现实际扣除{$cashExtRealPrice}元", $before, $after, $wechat_type);
  687. }
  688. }
  689. $wechat = \Yii::$app->controller->wechatPay;
  690. // $res = $wechat->transfer->toBalance($data);
  691. $res = (new \app\utils\WechatMerchant\WxV3($wechat))->transferBatches(get_store_id(), $data);
  692. //判断是否使用新版本转账 增加转账标识
  693. $wechat_cash = json_decode($wechat_cash, true);
  694. if (intval($wechat_cash['is_open']) === 2) {
  695. if (!$res['code']) {
  696. $cash->is_platform_transfers = intval($store->is_platform_transfers);
  697. $cash->wx_cash_type = Cash::WX_CASH_TYPE_NEW;
  698. $cash->wx_cash_state = $res['data']['state'];
  699. $cash->wx_cash_result_info = json_encode($res['data'], JSON_UNESCAPED_UNICODE);
  700. $cash->save();
  701. }
  702. }
  703. NoticeSend::CashSuccess($cash->user_id, $user->binding, $price, '微信自动打款', ($cash->price - $price));
  704. } elseif ((int)$cash->type === 1) {
  705. $order = (object)[
  706. 'store_id' => $cash->store_id,
  707. 'order_no' => $cash->order_no,
  708. 'pay_price' => sprintf("%.2f", $price),
  709. 'name' => $cash->name
  710. ];
  711. $result = Alipay::transfer($order, $cash->mobile);
  712. if (isset($result['code']) && $result['code'] == 1) {
  713. if (strpos($result['msg'], 'aop.invalid-app-auth-token-no-api')) {
  714. $result['msg'] = '接口未授权,请前往支付宝开放平台查询是否开通产品或授权支付宝转账产品';
  715. }
  716. if (strpos($result['msg'], 'PAYEE_NOT_EXIST')) {
  717. $result['msg'] = '收款账号不存在或姓名有误,建议核实账号和姓名是否准确';
  718. }
  719. if (strpos($result['msg'], 'BALANCE_IS_NOT_ENOUGH')) {
  720. $result['msg'] = '商户余额不足';
  721. }
  722. return $this->asJson($result);
  723. } else {
  724. // TODO 扣除店铺提现金额
  725. if ($wechat_type == 0) {
  726. $cashExt = CashExt::findOne(['cash_id' => $cash->id, 'cash_price_type' => CashExt::CASH_PRICE_TYPE_AMOUNT]);
  727. $before = $store->store_balance;
  728. $store->store_balance -= $cashExt ? $cashExt->real_price : $price;
  729. $store->price -= $cashExt ? $cashExt->real_price : $price;
  730. $store->store_withdrawn_cash += $cashExt ? $cashExt->real_price : $price;
  731. $after = $store->store_balance;
  732. $cashExtServePrice = $cashExt ? bcsub($cashExt->price, $cashExt->real_price, 2) : $servePrice;
  733. $cashExtPrice = $cashExt ? $cashExt->price : $cash->price;
  734. $cashExtRealPrice = $cashExt ? $cashExt->real_price : $price;
  735. if ($store->save()) {
  736. StoreMoneyLog::saveLog(get_store_id(), StoreMoneyLog::LOG_TYPE_EXPEND, StoreMoneyLog::TYPE_SHARE, $cashExtRealPrice, " ID{$id}:用户提现{$cashExtPrice}元,扣除手续费{$cashExtServePrice}元,提现实际扣除{$cashExtRealPrice}元", $before, $after, $wechat_type);
  737. }
  738. }
  739. }
  740. $cash->save();
  741. $t->commit();
  742. return $this->asJson([
  743. 'code' => 0,
  744. 'msg' => '成功'
  745. ]);
  746. }elseif ((int)$cash->type === 4) {
  747. $user = User::findOne($cash->user_id);
  748. $saas = SaasUser::findOne(['mobile' => $user->binding]);
  749. $lg_info = Lg::find()->where(['user_id'=>$saas->id,'status'=>1,'is_delete'=>0])->one();
  750. $lgApi = new LgApi($cash->store_id);
  751. //灵工提现
  752. $post_data = [
  753. 'store_id' => $cash->store_id,
  754. 'outTradeNo' => $cash->order_no,//唯一批次号
  755. 'accNo' => bcmul($price,100),
  756. 'amt' => bcmul($price,100),
  757. 'name' => $lg_info->name,
  758. 'certCard' => $lg_info->cert_card//身份证号
  759. ];
  760. $result = $lgApi->FlexiblePay($post_data);
  761. if (isset($result['status']) && $result['status'] == 999) {
  762. return $this->asJson($result);
  763. }
  764. $cash->status = 6;//灵工待打款
  765. $cash->save();
  766. $t->commit();
  767. //灵工提现接口调用后消息队列查询状态
  768. \queue_push(new LgCashJob(['id'=>$cash->id,'store_id'=>$store_id,'type'=>0,'retry' => 5]), 60);
  769. return $this->asJson([
  770. 'code' => 0,
  771. 'msg' => '成功'
  772. ]);
  773. }
  774. } elseif ($status == Cash::STATUS_HAND) { //手动打款
  775. $user = User::findOne($cash->user_id);
  776. // TODO 扣除店铺提现金额
  777. if ($wechat_type == 0) {
  778. $cashExt = CashExt::findOne(['cash_id' => $cash->id, 'cash_price_type' => CashExt::CASH_PRICE_TYPE_AMOUNT]);
  779. $before = $store->store_balance;
  780. $store->store_balance -= $cashExt ? $cashExt->real_price : $price;
  781. $store->price -= $cashExt ? $cashExt->real_price : $price;
  782. $store->store_withdrawn_cash += $cashExt ? $cashExt->real_price : $price;
  783. $after = $store->store_balance;
  784. $cashExtServePrice = $cashExt ? bcsub($cashExt->price, $cashExt->real_price, 2) : $servePrice;
  785. $cashExtPrice = $cashExt ? $cashExt->price : $cash->price;
  786. $cashExtRealPrice = $cashExt ? $cashExt->real_price : $price;
  787. if ($store->save()) {
  788. StoreMoneyLog::saveLog(get_store_id(), StoreMoneyLog::LOG_TYPE_EXPEND, StoreMoneyLog::TYPE_SHARE, $cashExtRealPrice, " ID{$id}:用户提现{$cashExtPrice}元,扣除手续费{$cashExtServePrice}元,提现实际扣除{$cashExtRealPrice}元", $before, $after, $wechat_type);
  789. } else {
  790. $t->rollBack();
  791. }
  792. }
  793. $cash->status = Cash::STATUS_HAND;
  794. $cash->pay_time = time();
  795. $cash->pay_type = Cash::PAY_TYPE_HAND;
  796. if ($cash->type == Cash::TYPE_RECHARGE) {
  797. $cashExt = CashExt::findOne(['cash_id' => $cash->id, 'cash_price_type' => CashExt::CASH_PRICE_TYPE_AMOUNT]);
  798. if ($cashExt && $cashExt->real_price > 0) {
  799. AccountLog::saveLog($cash->user_id, $cashExt->real_price, 2, 1, 0, 0, '佣金提现打款');
  800. }
  801. }
  802. $res['result_code'] = "SUCCESS";
  803. NoticeSend::CashSuccess($cash->user_id, $user->binding, $cashExt ? $cashExt->real_price : $price, '手动打款', ($cash->price - ($cashExt ? $cashExt->real_price : $price)));
  804. }
  805. if (isset($res['result_code']) && $res['result_code'] == 'SUCCESS') {
  806. $cash->save();
  807. $t->commit();
  808. return $this->asJson([
  809. 'code' => 0,
  810. 'msg' => '成功'
  811. ]);
  812. } else {
  813. $t->rollBack();
  814. return $this->asJson([
  815. 'code' => 1,
  816. 'msg' => !empty($res['err_code_des']) ? $res['err_code_des'] : '请稍后重试',
  817. 'data' => $res
  818. ]);
  819. }
  820. }
  821. //saas确认打款
  822. public function actionSaasConfirm()
  823. {
  824. $id = post_params('id');
  825. $status = post_params('status');
  826. $store_id = get_store_id();
  827. $cash = Cash::findOne(['id' => $id, 'is_delete' => Cash::IS_DELETE_NO]);
  828. if (!$cash) {
  829. return $this->asJson([
  830. 'code' => 1,
  831. 'msg' => '提现记录不存在,请刷新重试'
  832. ]);
  833. }
  834. if (!$cash->order_no) {
  835. $order_no = null;
  836. while (true) {
  837. $order_no = date('YmdHis') . mt_rand(100000, 999999);
  838. $exist_order_no = Cash::find()->where(['order_no' => $order_no])->exists();
  839. if (!$exist_order_no) {
  840. break;
  841. }
  842. }
  843. $cash->order_no = $order_no;
  844. $cash->save();
  845. }
  846. if ($cash->status != 1) {
  847. return $this->asJson([
  848. 'code' => 1,
  849. 'msg' => '操作错误,请刷新重试'
  850. ]);
  851. }
  852. $res = [];
  853. $price = Cash::getServiceMoney($cash);
  854. if ($status == Cash::STATUS_GIVEN) { //微信自动打款
  855. $cash->status = Cash::STATUS_GIVEN;
  856. $cash->pay_time = time();
  857. $cash->pay_type = Cash::PAY_TYPE_WX;
  858. $saas = SaasUser::findOne(['id' => $cash->saas_id]);
  859. $data = [
  860. 'partner_trade_no' => $cash->order_no,
  861. 'openid' => $saas->platform_open_id,
  862. 'check_name' => 'NO_CHECK',
  863. 'amount' => $price * 100,
  864. 'desc' => '转账',
  865. 'user_name' => $cash->name
  866. ];
  867. // $WechatConfig = WechatConfig::findOne(['store_id' => get_store_id()]);
  868. // if (empty($WechatConfig->mch_id) || empty($WechatConfig->pay_key) || empty($WechatConfig->app_id)|| empty($WechatConfig->cert_pem)|| empty($WechatConfig->key_pem)) {
  869. // return $this->asJson([
  870. // 'code' => 1,
  871. // 'msg' => "后台参数配置错误,请检查参数后重试"
  872. // ]);
  873. // }
  874. $store = Store::findOne($store_id);
  875. $wechat_cash = Option::get('wechat_cash', $store_id, 'store')['value'];
  876. if($store->is_platform_transfers == 1){
  877. $wechat_cash = Option::get('store_wechat_cash', $store_id, 'store')['value'];
  878. }
  879. $wechat = \Yii::$app->controller->wechatPay;
  880. // $res = $wechat->transfer->toBalance($data);
  881. $res = (new \app\utils\WechatMerchant\WxV3($wechat))->transferBatches(get_store_id(), $data);
  882. //判断是否使用新版本转账 增加转账标识
  883. $wechat_cash = json_decode($wechat_cash, true);
  884. if (intval($wechat_cash['is_open']) === 2) {
  885. if (!$res['code']) {
  886. $cash->is_platform_transfers = intval($store->is_platform_transfers);
  887. $cash->wx_cash_type = Cash::WX_CASH_TYPE_NEW;
  888. $cash->wx_cash_state = $res['data']['state'];
  889. $cash->wx_cash_result_info = json_encode($res['data'], JSON_UNESCAPED_UNICODE);
  890. $cash->save();
  891. }
  892. }
  893. //NoticeSend::CashSuccess($cash->user_id, $user->binding, $price, '微信自动打款', ($cash->price - $price));
  894. } elseif ($status == Cash::STATUS_HAND) { //手动打款
  895. $cash->status = Cash::STATUS_GIVEN;
  896. $cash->pay_time = time();
  897. $cash->pay_type = Cash::PAY_TYPE_HAND;
  898. // if ($cash->type == Cash::TYPE_RECHARGE) {
  899. // $user = User::findOne(['id' => $cash->user_id]);
  900. // $user->money += doubleval($price);
  901. // if (!$user->save()) {
  902. // \Yii::$app->cache->set('cash_cache_' . $id, false);
  903. // foreach ($user->errors as $error) {
  904. // return $this->asJson([
  905. // 'code' => 1,
  906. // 'msg' => $error
  907. // ]);
  908. // }
  909. // }
  910. // }
  911. $res['result_code'] = "SUCCESS";
  912. //NoticeSend::CashSuccess($cash->user_id, $user->binding, $price, '手动打款', ($cash->price - $price));
  913. }
  914. if (isset($res['result_code']) && $res['result_code'] == 'SUCCESS') {
  915. $cash->save();
  916. return $this->asJson([
  917. 'code' => 0,
  918. 'msg' => '成功'
  919. ]);
  920. } else {
  921. return $this->asJson([
  922. 'code' => 1,
  923. 'msg' => !empty($res['err_code_des']) ? $res['err_code_des'] : '请稍后重试',
  924. 'data' => $res
  925. ]);
  926. }
  927. }
  928. /**
  929. * 订单
  930. * @return \yii\web\Response
  931. */
  932. public function actionOrder()
  933. {
  934. $store_id = get_store_id();
  935. $form = new ShareOrderForm();
  936. $form->attributes = get_params();
  937. $form->store_id = $store_id;
  938. $form->parent_id = get_params('parent_id') ? (int)get_params('parent_id') : false;
  939. $data = $form->search();
  940. foreach ($data['data']['data'] as &$item) {
  941. $order_detail = OrderDetail::find()->where(['order_id' => $item['id']])->select('delivery_type')->one();
  942. $item['delivery_type'] = $order_detail['delivery_type'];
  943. }
  944. $return = [
  945. 'code' => $data['code'],
  946. 'msg' => $data['msg'],
  947. 'data' => $data['data'],
  948. 'parent' => []
  949. ];
  950. if (get_params('parent_id')) {
  951. $user = User::findOne(['store_id' => $store_id, 'id' => get_params('parent_id')]);
  952. $return['parent'] = $user;
  953. }
  954. return $this->asJson($return);
  955. }
  956. /**
  957. * 充值订单
  958. * @return \yii\web\Response
  959. */
  960. public function actionTopUpOrder()
  961. {
  962. $store_id = get_store_id();
  963. $form = new RechargeForm();
  964. $form->attributes = get_params();
  965. $form->store_id = $store_id;
  966. $form->phone = get_params('phone');
  967. $form->order_no = get_params('order_no');
  968. $data = $form->search();
  969. $return = [
  970. 'code' => $data['code'],
  971. 'msg' => $data['msg'],
  972. 'data' => $data['data'],
  973. 'parent' => []
  974. ];
  975. return $this->asJson($return);
  976. }
  977. /**
  978. * @return string
  979. * 获取用户分销二维码
  980. */
  981. public function actionGetQrcode()
  982. {
  983. $form = new QrcodeForm();
  984. $form->attributes = get_params();
  985. $form->store_id = get_store_id();
  986. return $this->asJson($form->search());
  987. }
  988. /**
  989. * @return string
  990. * 设置推广海报
  991. */
  992. public function actionQrcode()
  993. {
  994. $store_id = get_store_id();
  995. //兼容联盟
  996. $is_saas = post_params('is_saas',0);
  997. if($is_saas){
  998. $store_id = -1;
  999. }
  1000. $qrcode = Qrcode::findOne(['store_id' => $store_id, 'is_delete' => 0, 'type' => Qrcode::TYPE_SHARE]);
  1001. if (!$qrcode) {
  1002. $qrcode = new Qrcode();
  1003. }
  1004. $form = new QrcodeForm();
  1005. $form->attributes = post_params();
  1006. $form->store_id = $store_id;
  1007. $form->qrcode = $qrcode;
  1008. $form->type = Qrcode::TYPE_SHARE;
  1009. return $this->asJson($form->save());
  1010. }
  1011. /**
  1012. * @return \yii\web\Response
  1013. */
  1014. public function actionGetQrcodeSetting()
  1015. {
  1016. //兼容联盟
  1017. $is_saas = get_params('is_saas',0);
  1018. if($is_saas){
  1019. $store_id = -1;
  1020. }else{
  1021. $store_id = get_store_id();
  1022. }
  1023. $qrcode = Qrcode::findOne(['store_id' => $store_id, 'is_delete' => 0, 'type' => Qrcode::TYPE_SHARE]);
  1024. // \Yii::error($qrcode->font);
  1025. $color = Color::find()->select('id, color')->andWhere(['is_delete' => 0])->asArray()->all();
  1026. $font_position = json_decode($qrcode->font_position, true);
  1027. $qrcode_position = json_decode($qrcode->qrcode_position, true);
  1028. $avatar_position = json_decode($qrcode->avatar_position, true);
  1029. $avatar_size = json_decode($qrcode->avatar_size, true);
  1030. $qrcode_size = json_decode($qrcode->qrcode_size, true);
  1031. $font_size = json_decode($qrcode->font, true);
  1032. $invite_position = json_decode($qrcode->invite_position, true);
  1033. // \Yii::error($font_size);
  1034. $first = Color::findOne(['color' => $font_size['color']]);
  1035. $res = [
  1036. 'qrcode_bg' => $qrcode->qrcode_bg ?: \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/2_1.png',
  1037. 'qrcode_pic' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/1.png',
  1038. 'avatar' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/avatar.png',
  1039. 'qrcode' => $qrcode,
  1040. 'color' => $color,
  1041. 'first' => $first->id,
  1042. 'font_c' => Json::decode($qrcode->font, true)['color'] ? Json::decode($qrcode->font, true)['color'] : ($first->color ?: "#000"),
  1043. 'avatar_w' => $avatar_size['w'] ?: '63',
  1044. 'avatar_x' => $avatar_position['x'] ?: '50',
  1045. 'avatar_y' => $avatar_position['y'] ?: '160',
  1046. 'qrcode_w' => $qrcode_size['w'] ?: '169',
  1047. 'qrcode_c' => empty($qrcode_size['c']) ? 1 : (($qrcode_size['c'] == "true") ? 1 : 0),
  1048. 'qrcode_x' => $qrcode_position['x'] ?: '65',
  1049. 'qrcode_y' => $qrcode_position['y'] ?: '240',
  1050. 'font_x' => $font_position['x'] ?: '124',
  1051. 'font_y' => $font_position['y'] ?: '180',
  1052. 'font_w' => $font_size['size'] ?: '20',
  1053. 'invite_x' => $invite_position['x'] ?: '0',
  1054. 'invite_y' => $invite_position['y'] ?: '0',
  1055. ];
  1056. return $this->asJson(['code' => 0, 'msg' => 'success', 'data' => $res]);
  1057. }
  1058. /**
  1059. * 提现明细列表
  1060. */
  1061. public function actionCashDetail()
  1062. {
  1063. $form = new CashListForm();
  1064. $form->attributes = get_params();
  1065. $form->store_id = get_store_id();
  1066. $form->user_id = get_user_id();
  1067. return $this->asJson($form->getList());
  1068. }
  1069. public function actionAddShare()
  1070. {
  1071. $user_id = post_params('user_id', 0);
  1072. $mobile = post_params('mobile', '');
  1073. $name = post_params('name', '');
  1074. $store_id = get_store_id();
  1075. $user = User::findOne($user_id);
  1076. if (!$user) {
  1077. return $this->asJson([
  1078. 'code' => 1,
  1079. 'msg' => '用户信息查询失败'
  1080. ]);
  1081. }
  1082. $share = Share::findOne(['user_id' => $user_id, 'is_delete' => 0, 'status' => [0, 1]]);
  1083. if ($user->is_distributor || $share) {
  1084. return $this->asJson([
  1085. 'code' => 1,
  1086. 'msg' => '用户已经是分销商或审核中'
  1087. ]);
  1088. }
  1089. $share = new Share();
  1090. $share->user_id = $user_id;
  1091. $share->mobile = $mobile;
  1092. $share->name = $name;
  1093. $share->is_delete = 0;
  1094. $share->store_id = $store_id;
  1095. $share->status = 1;
  1096. $share->created_at = time();
  1097. if (!$share->save()) {
  1098. return $this->asJson([
  1099. 'code' => 1,
  1100. 'msg' => implode(';', array_values($share->firstErrors))
  1101. ]);
  1102. }
  1103. $user->time = time();
  1104. $user->is_distributor = 1;
  1105. if (!$user->save()) {
  1106. return $this->asJson([
  1107. 'code' => 1,
  1108. 'msg' => implode(';', array_values($user->firstErrors))
  1109. ]);
  1110. }
  1111. return $this->asJson([
  1112. 'code' => 0,
  1113. 'msg' => "添加分销商成功"
  1114. ]);
  1115. }
  1116. public function actionShareChildList()
  1117. {
  1118. $form = new ShareOrderForm();
  1119. $form->attributes = get_params();
  1120. $form->store_id = get_store_id();
  1121. return $this->asJson($form->shareChildList());
  1122. }
  1123. }