|
|
@@ -3,15 +3,18 @@
|
|
3
|
3
|
namespace app\common\repositories\shared;
|
|
4
|
4
|
|
|
5
|
5
|
use app\common\dao\shared\SharedProsperityGroupUserDao;
|
|
|
6
|
+use app\common\dao\shared\SharedProsperityRewardRecordDao;
|
|
6
|
7
|
use app\common\dao\shared\SharedProsperityUserDao;
|
|
7
|
8
|
use app\common\dao\user\UserDao;
|
|
8
|
9
|
use app\common\enum\CommonEnum;
|
|
|
10
|
+use app\common\enum\shared\SharedProsperityRewardRecordEnum;
|
|
9
|
11
|
use app\common\enum\shared\SharedProsperityUserEnum;
|
|
10
|
12
|
use app\common\model\user\User;
|
|
11
|
13
|
use app\common\repositories\BaseRepository;
|
|
12
|
14
|
use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
|
|
13
|
15
|
use app\entity\data\shared\SharedProsperityUserEntity;
|
|
14
|
16
|
use think\db\exception\DbException;
|
|
|
17
|
+use think\facade\Db;
|
|
15
|
18
|
|
|
16
|
19
|
class SharedProsperityUserRepository extends BaseRepository
|
|
17
|
20
|
{
|
|
|
@@ -698,7 +701,7 @@ class SharedProsperityUserRepository extends BaseRepository
|
|
698
|
701
|
* @param $userId
|
|
699
|
702
|
* @param $type
|
|
700
|
703
|
* @param $number
|
|
701
|
|
- * @return int|mixed
|
|
|
704
|
+ * @return bool
|
|
702
|
705
|
* @author 史晨
|
|
703
|
706
|
* @date 2026/2/27 15:16
|
|
704
|
707
|
* 更新用户奖励
|
|
|
@@ -710,13 +713,77 @@ class SharedProsperityUserRepository extends BaseRepository
|
|
710
|
713
|
1002 => 'withdrawal_limit',
|
|
711
|
714
|
1003 => 'pv'
|
|
712
|
715
|
];
|
|
713
|
|
- if (isset($map[$type])) {
|
|
714
|
|
- $res = $this->dao->updateRewardByUserId($userId, $map[$type], $number);
|
|
715
|
|
- } else {
|
|
716
|
|
- /** @var UserDao $userDao */
|
|
717
|
|
- $userDao = app()->make(UserDao::class);
|
|
718
|
|
- $res = $userDao->updateBrokeragePriceByUid($userId, $number);;
|
|
|
716
|
+
|
|
|
717
|
+ try {
|
|
|
718
|
+ Db::startTrans();
|
|
|
719
|
+
|
|
|
720
|
+ $pm = 1;
|
|
|
721
|
+ $remark = '后台操作增加' . $number;
|
|
|
722
|
+ if ($number < 0) {
|
|
|
723
|
+ $pm = 0;
|
|
|
724
|
+ $remark = '后台操作减少' . abs($number);
|
|
|
725
|
+ }
|
|
|
726
|
+
|
|
|
727
|
+ if (isset($map[$type])) {
|
|
|
728
|
+ // 更新数据
|
|
|
729
|
+ $this->dao->updateRewardByUserId($userId, $map[$type], $number);
|
|
|
730
|
+ // 记录日志
|
|
|
731
|
+ $insertData = [
|
|
|
732
|
+ 'user_id' => $userId,
|
|
|
733
|
+ 'type' => $type,
|
|
|
734
|
+ 'pm' => $pm,
|
|
|
735
|
+ 'number' => abs($number),
|
|
|
736
|
+ 'balance' => 0,
|
|
|
737
|
+ 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'],
|
|
|
738
|
+ 'type_shop' => SharedProsperityRewardRecordEnum::TYPE_SHOP['Platform']['code'],
|
|
|
739
|
+ 'order_sn' => 0,
|
|
|
740
|
+ 'take_time' => date('Y-m-d H:i:s', time()),
|
|
|
741
|
+ 'remark' => $remark,
|
|
|
742
|
+ 'create_time' => date('Y-m-d H:i:s', time()),
|
|
|
743
|
+ 'update_time' => date('Y-m-d H:i:s', time()),
|
|
|
744
|
+ ];
|
|
|
745
|
+ /** @var SharedProsperityRewardRecordDao $rewardRecordDao */
|
|
|
746
|
+ $rewardRecordDao = app()->make(SharedProsperityRewardRecordDao::class);
|
|
|
747
|
+ $rewardRecordDao->insertAll([$insertData]);
|
|
|
748
|
+ } else {
|
|
|
749
|
+ // 更新数据
|
|
|
750
|
+ /** @var UserDao $userDao */
|
|
|
751
|
+ $userDao = app()->make(UserDao::class);
|
|
|
752
|
+ $userDao->updateBrokeragePriceByUid($userId, $number);;
|
|
|
753
|
+ // 记录日志
|
|
|
754
|
+ $bill = [
|
|
|
755
|
+ 'uid' => $userId,
|
|
|
756
|
+ 'link_id' => 0,
|
|
|
757
|
+ 'pm' => $pm,
|
|
|
758
|
+ 'title' => $remark,
|
|
|
759
|
+ 'category' => 'now_money',
|
|
|
760
|
+ 'type' => 'commission',
|
|
|
761
|
+ 'number' => abs($number),
|
|
|
762
|
+ 'balance' => 0,
|
|
|
763
|
+ 'mark' => $remark,
|
|
|
764
|
+ 'create_time' => date('Y-m-d H:i:s'),
|
|
|
765
|
+ 'status' => 1,
|
|
|
766
|
+ 'commission_type' => CommonEnum::COMMISSION_TYPE['SHARED_PROSPERITY_PARTNER_COMMISSION']['code'],
|
|
|
767
|
+ 'order_sn' => 0,
|
|
|
768
|
+ 'tripartite' => 0,
|
|
|
769
|
+ 'type_shop' => 0,
|
|
|
770
|
+ 'mer_id' => 0,
|
|
|
771
|
+ 'source' => 0,
|
|
|
772
|
+ 'order_type' => 1,
|
|
|
773
|
+ 'is_red_brokerage' => 0,
|
|
|
774
|
+ 'gzc' => 3,
|
|
|
775
|
+ 'take_time' => time(),
|
|
|
776
|
+ 'district_id' => '',
|
|
|
777
|
+ 'street_id' => '',
|
|
|
778
|
+ 'month' => '',
|
|
|
779
|
+ ];
|
|
|
780
|
+ Db::name('user_bill')->insert($bill);
|
|
|
781
|
+ }
|
|
|
782
|
+ Db::commit();
|
|
|
783
|
+ return true;
|
|
|
784
|
+ } catch (\Exception $e) {
|
|
|
785
|
+ Db::rollback();
|
|
|
786
|
+ return false;
|
|
719
|
787
|
}
|
|
720
|
|
- return $res;
|
|
721
|
788
|
}
|
|
722
|
789
|
}
|