41 次代碼提交 49fe971ca3 ... 34cb776af0

作者 SHA1 備註 提交日期
  xupuyuan 34cb776af0 商品分类-取消硬编码-修复错误 8 月之前
  xupuyuan c4c048cdd9 Merge branch 'master' into dev 8 月之前
  xupuyuan 67ba2235e4 商品分类-取消硬编码 8 月之前
  shichen 1d4b245f71 feat(store): 添加购物车商品ID列表查询功能并优化订单幸福币发放逻辑 8 月之前
  shichen a4aa2386b6 feat(order): 添加共富区订单幸福币发放和结算功能 8 月之前
  shichen 645c5465a4 fix(user): 添加参数验证防止空类型查询 8 月之前
  shichen 364a6415ce feat(api): 添加幸福币记录功能 8 月之前
  shichen cf29964932 fix(order): 修复订单计算中的数量乘积错误 8 月之前
  shichen 2f797aae02 fix(order): 修复订单计算中的精度问题 8 月之前
  shichen 75cf0ac7b5 feat(product): 添加养老金计算功能 8 月之前
  shichen 1d3176cf70 fix(order): 修复订单养老金计算逻辑 8 月之前
  shichen a8598c1986 fix(order): 精彩生活区修复养老金额计算逻辑 8 月之前
  shichen c839b882e7 fix(order): 修复订单养老金计算逻辑错误 8 月之前
  shichen 3392a048fb fix(order): 修复订单计算中积分金额未乘以购物车数量的问题 8 月之前
  shichen 7334e459e3 fix(order): 修复订单价格计算错误 8 月之前
  shichen 2e11764dcd fix(order): 修复订单状态检查逻辑 8 月之前
  shichen 6f72669364 fix(order): 修复订单状态检查逻辑 8 月之前
  shichen 6ae15f96b1 fix(auth): 修复推荐人绑定逻辑错误 8 月之前
  shichen d08c6e8e61 refactor(store): 注释掉养老金相关记录逻辑 8 月之前
  xupuyuan 4c2b0f9751 Merge branch 'dev' 8 月之前
  xupuyuan 203b941a67 Merge branch 'dev-xpy' into dev 8 月之前
  xupuyuan f9dc1d02bd Merge branch 'dev-xpy' into dev 8 月之前
  xupuyuan 39a9971723 Merge branch 'dev-xpy' into dev 8 月之前
  xupuyuan 9296941900 Merge branch 'dev' 8 月之前
  shichen 2dfafe1d2a fix(task): 修正系统补贴金额配置 8 月之前
  shichen ade94aef04 fix(task): 更新分红金额配置 8 月之前
  xupuyuan 9092103120 Merge branch 'dev-xpy' into dev 8 月之前
  shichen b376d36a04 fix(api): 修正测试数据中的概率配置 8 月之前
  shichen 324579b8a0 fix(finance): 修复统计数据中排除测试用户的问题 8 月之前
  shichen eb1310c966 refactor(test): 计算共富分红 8 月之前
  shichen bf4082737b fix(finance): 排除测试账号数据统计 8 月之前
  QuliKnight@users.noreply.github.com 7acfbb7b76 Merge branch 'dev-xpy' into dev 8 月之前
  shichen c3c6e6e160 fix(merchant): 修复商户贡献数据创建时间格式问题 8 月之前
  shichen 1ab5669860 fix(admin): 排除测试订单统计 8 月之前
  shichen aa615ce638 fix(order): 修复日订单金额统计逻辑 8 月之前
  shichen 1652f55658 feat(console): 添加共富区线下扫码订单分账回撤功能 8 月之前
  shichen bcac86c067 fix(order): 修复订单处理中养老金发放逻辑 8 月之前
  shichen 1e4915b136 Merge branch 'dev' 8 月之前
  shichen c2925b2040 chore(order): 注释掉推荐人养老金发放相关代码 8 月之前
  shichen e7e2df62eb feat(express): 添加物流查询中的发货类型参数支持 8 月之前
  shichen 7f05e8d6ae fix(finance): 修复周统计时间范围查询条件 8 月之前

+ 140 - 0
app/command/SharedOfflineOrderProfitDelete.php

@@ -0,0 +1,140 @@
1
+<?php
2
+
3
+namespace app\command;
4
+
5
+use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
6
+use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
7
+use think\console\Command;
8
+use think\console\Input;
9
+use think\console\Output;
10
+use think\facade\Db;
11
+
12
+class SharedOfflineOrderProfitDelete extends Command
13
+{
14
+    // 变更数量
15
+    const NUMBER = 5;
16
+
17
+    const CONFIG_ID = 2;
18
+
19
+    protected function configure()
20
+    {
21
+        // 指令配置
22
+        $this->setName('sharedOfflineOrderProfitDelete')
23
+            ->setDescription('共富区线下扫码订单分账回撤');
24
+    }
25
+
26
+    protected function execute(Input $input, Output $output)
27
+    {
28
+        $output->writeln('定时任务执行中...');
29
+
30
+        $this->delete();
31
+
32
+        $output->writeln('定时任务执行完成');
33
+    }
34
+
35
+    private function delete()
36
+    {
37
+        $ids = [
38
+            13799,
39
+            13798,
40
+            13795,
41
+            13784,
42
+            13775,
43
+            13774,
44
+            13773,
45
+            13754,
46
+            13753,
47
+            13750,
48
+            13749
49
+        ];
50
+        $orderData = Db::name('order_merchant')
51
+            ->where(['id' => $ids])
52
+            ->select()
53
+            ->toArray();
54
+
55
+        Db::startTrans();
56
+        try {
57
+            foreach ($orderData as $order) {
58
+                // bill表
59
+                $billData = Db::name('user_bill')->where(['order_sn' => $order['out_trade_no']])->select()->toArray();
60
+                foreach ($billData as $bill) {
61
+                    // 消费者本人和推荐人养老金数据删除
62
+                    if ($bill['commission_type'] == 5) {
63
+                        Db::name('user_bill')->where(['bill_id' => $bill['bill_id']])->delete();
64
+                    }
65
+
66
+                    // 商户跨店佣金删除
67
+                    if ($bill['commission_type'] == 7) {
68
+                        Db::name('user_bill')->where(['bill_id' => $bill['bill_id']])->delete();
69
+                        Db::name("user")->where("uid", $bill['uid'])->dec('brokerage_price', $bill['number'])->update();
70
+                    }
71
+
72
+                    // 佣金删除
73
+                    if ($bill['commission_type'] == 3) {
74
+                        Db::name('user_bill')->where(['bill_id' => $bill['bill_id']])->delete();
75
+                        Db::name("user")->where("uid", $bill['uid'])->dec('brokerage_price', $bill['number'])->update();
76
+                    }
77
+                }
78
+
79
+                // 删除红包数据和用户表字段数据
80
+                $red = Db::name('user_sign_hongbao')->where(['order_id' => $order['id']])->find();
81
+                if ($red) {
82
+                    Db::name('user_sign_hongbao')->where(['id' => $red['id']])->delete();
83
+                    Db::name('user')->where(['uid' => $red['uid']])->dec('hongbao', $red['number'])->update();
84
+                }
85
+
86
+                // 删除积分数据和用户表字段数据
87
+                $scoreData = Db::name('user_sign_score')->where(['order_id' => $order['id']])->select()->toArray();
88
+                if ($scoreData) {
89
+                    foreach ($scoreData as $score) {
90
+                        Db::name('user_sign_score')->where(['id' => $score['id']])->delete();
91
+                        Db::name('user')->where(['uid' => $score['uid']])->dec('score', $score['reward_socre'])->update();
92
+                    }
93
+                }
94
+
95
+                // 删除贡献值数据和用户表字段数据
96
+                $contributionData = Db::name('user_sign_gongxian')->where(['order_id' => $order['id']])->select()->toArray();
97
+                if ($contributionData) {
98
+                    foreach ($contributionData as $contribution) {
99
+                        Db::name('user_sign_gongxian')->where(['id' => $contribution['id']])->delete();
100
+                        Db::name('user')->where(['uid' => $contribution['uid']])->dec('contribute', $contribution['number'])->update();
101
+                    }
102
+                }
103
+
104
+                // pv
105
+                $pvData = Db::name('user_pv_log')->where(['order_id' => $order['id']])->find();
106
+                if ($pvData) {
107
+                    Db::name('user_pv_log')->where(['id' => $pvData['id']])->delete();
108
+                    Db::name('user')->where(['uid' => $pvData['uid']])->dec('pv', $pvData['pv'])->update();
109
+                }
110
+
111
+                // 复购金
112
+                $rebuyData = Db::name('user_sign_fugou')->where(['order_id' => $order['id']])->find();
113
+                if ($rebuyData) {
114
+                    Db::name('user_sign_fugou')->where(['id' => $rebuyData['id']])->delete();
115
+                    Db::name('user')->where(['uid' => $rebuyData['uid']])->dec('fugou', $rebuyData['number'])->update();
116
+                }
117
+
118
+                // 商户得到的京豆
119
+                $beanData = Db::name('user_sign_jingdou')->where(['order_id' => $order['id']])->find();
120
+                if ($beanData) {
121
+                    Db::name('user_sign_jingdou')->where(['id' => $beanData['id']])->delete();
122
+                    Db::name('user')->where(['uid' => $beanData['uid']])->dec('jingdou', $beanData['number'])->update();
123
+                }
124
+
125
+                //扫码下单产生分润值
126
+                $profitData = Db::name('user_sign_fenrun')->where(['order_id' => $order['id']])->find();
127
+                if ($profitData) {
128
+                    Db::name('user_sign_fenrun')->where(['id' => $profitData['id']])->delete();
129
+                }
130
+            }
131
+            Db::commit();
132
+            return true;
133
+        } catch (\Exception $e) {
134
+            Db::rollback();
135
+            dd($e->getFile(),$e->getMessage(),$e->getLine());
136
+        }
137
+
138
+    }
139
+
140
+}

+ 22 - 0
app/common/dao/store/order/StoreCartDao.php

@@ -246,4 +246,26 @@ class StoreCartDao extends BaseDao
246 246
         }
247 247
         return $entityList;
248 248
     }
249
+
250
+    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
251
+    {
252
+        $entityList = [];
253
+        try {
254
+            /** @var StoreCart $model */
255
+            $model = $this->getModel();
256
+            $dataListRes = $model::getDB()
257
+                ->where('uid', '=', $uid)
258
+                ->whereIn('product_id', $productIdList)
259
+                ->select()
260
+                ->toArray();
261
+            if (!empty($dataListRes)) {
262
+                foreach ($dataListRes as $data) {
263
+                    $entityList[] = CartEntity::newInstance($data);
264
+                }
265
+            }
266
+        } catch (\Exception $e) {
267
+        }
268
+        return $entityList;
269
+    }
270
+
249 271
 }

+ 1 - 1
app/common/dao/store/order/StoreOrderDao.php

@@ -315,7 +315,7 @@ class StoreOrderDao extends BaseDao
315 315
 
316 316
     public function dayOrderPrice($day, $merId = null)
317 317
     {
318
-        return getModelTime(StoreOrder::getDB()->where('paid', 1)->when($merId, function ($query, $merId) {
318
+        return getModelTime(StoreOrder::getDB()->where('paid', 1)->where('test_order', 0)->when($merId, function ($query, $merId) {
319 319
             $query->where('mer_id', $merId);
320 320
         }), $day, 'pay_time')->sum('pay_price');
321 321
     }

+ 2 - 0
app/common/dao/system/merchant/MerchantContributionDao.php

@@ -40,6 +40,8 @@ class MerchantContributionDao extends BaseDao
40 40
         } catch (\Exception $e) {
41 41
 
42 42
         }
43
+        // 类型转换
44
+        $data['create_time'] = strtotime($data['create_time']);
43 45
         return MerchantContributionEntity::newInstance($data);
44 46
     }
45 47
 }

+ 20 - 0
app/common/dao/user/UserSignXfbDao.php

@@ -0,0 +1,20 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\BaseModel;
7
+use app\common\model\user\UserSignVr;
8
+use app\entity\CommonEntity;
9
+use app\entity\data\user\UserSignVrEntity;
10
+
11
+class UserSignXfbDao extends BaseDao
12
+{
13
+    /**
14
+     * @return BaseModel
15
+     */
16
+    protected function getModel(): string
17
+    {
18
+        return UserSignVr::class;
19
+    }
20
+}

+ 19 - 0
app/common/model/user/UserSignXfb.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserSignXfb extends BaseModel
8
+{
9
+
10
+    public static function tablePk(): string
11
+    {
12
+        return 'id';
13
+    }
14
+
15
+    public static function tableName(): string
16
+    {
17
+        return 'user_sign_xfb';
18
+    }
19
+}

+ 14 - 4
app/common/repositories/finance/FinanceRepository.php

@@ -388,7 +388,9 @@ class FinanceRepository extends BaseRepository
388 388
             $data['tow'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($maker[0]['count'] ?? 0), 'name' => '商户', 'user_group' => 0];
389 389
 
390 390
             // 共富会员身份
391
-            $sharedUserDataQuery = Db::query("SELECT partner_level,count(user_id) count FROM `rrx_shared_prosperity_user` group by partner_level");
391
+            $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
392
+            $testUidsStr = implode(',',$testUids);
393
+            $sharedUserDataQuery = Db::query("SELECT partner_level,count(user_id) count FROM `rrx_shared_prosperity_user` where user_id not in (".$testUidsStr.") group by partner_level");
392 394
             $sharedUserDataQuery = array_column($sharedUserDataQuery, 'count', 'partner_level');
393 395
             $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[0] ?? 0), 'name' => '普通用户', 'partner_level' => 0];
394 396
             $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[1] ?? 0), 'name' => '一星合伙人', 'partner_level' => 1];
@@ -399,7 +401,7 @@ class FinanceRepository extends BaseRepository
399 401
             $data['three'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedUserDataQuery[6] ?? 0), 'name' => '联席主席团', 'partner_level' => 6];
400 402
 
401 403
             // 共富百人团、千人团、万人团数据
402
-            $sharedGroupUserDataQuery = Db::query("SELECT group_id,count(user_id) count FROM `rrx_shared_prosperity_group_user` group by group_id");
404
+            $sharedGroupUserDataQuery = Db::query("SELECT group_id,count(user_id) count FROM `rrx_shared_prosperity_group_user` where user_id not in (".$testUidsStr.") group by group_id");
403 405
             $sharedGroupUserDataQuery = array_column($sharedGroupUserDataQuery, 'count', 'group_id');
404 406
             $data['four'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedGroupUserDataQuery[1] ?? 0), 'name' => '万人团', 'group_id' => 1];
405 407
             $data['four'][] = ['className' => 'el-icon-s-goods', 'count' => (int)($sharedGroupUserDataQuery[2] ?? 0), 'name' => '千人团', 'group_id' => 2];
@@ -501,27 +503,35 @@ class FinanceRepository extends BaseRepository
501 503
         $lastMonday->setISODate($year, $week - 1, 1);
502 504
 
503 505
         //上周时间条件
504
-        $sWeekWhere .= " and DATE(create_time) >= '" . $lastMonday->format('Y-m-d') . "' and DATE(create_time) <= '" . $thisMonday->format('Y-m-d') . "'";
506
+        $sWeekWhere .= " and DATE(create_time) >= '" . $lastMonday->format('Y-m-d') . "' and DATE(create_time) < '" . $thisMonday->format('Y-m-d') . "'";
505 507
         //周时间条件
506
-        $weekWhere .= " and DATE(create_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(create_time) <= '" . $nextMonday->format('Y-m-d') . "'";
508
+        $weekWhere .= " and DATE(create_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(create_time) < '" . $nextMonday->format('Y-m-d') . "'";
507 509
         //今日时间条件
508 510
         $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
511
+
512
+        // 测试账号
513
+        $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
514
+
509 515
         $sharedUserCount = Db::name('shared_prosperity_user')->count(); //共富会员总人数
510 516
         $sharedUserDayCount = Db::name('shared_prosperity_user')->where($dayWhere)->count(); //共富今日新增会员
511 517
         $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
512 518
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
519
+            ->whereNotIn('user_id',$testUids)
513 520
             ->sum('number'); // 共富会员专区总业绩
514 521
         $sharedUserLastWeekPv = Db::name('shared_prosperity_reward_record')
515 522
             ->where($sWeekWhere)
516 523
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
524
+            ->whereNotIn('user_id',$testUids)
517 525
             ->sum('number'); // 共富会员专区上周总业绩
518 526
         $sharedUserWeekPv = Db::name('shared_prosperity_reward_record')
519 527
             ->where($weekWhere)
520 528
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
529
+            ->whereNotIn('user_id',$testUids)
521 530
             ->sum('number'); // 共富会员专区本周总业绩
522 531
         $sharedUserTodayPv = Db::name('shared_prosperity_reward_record')
523 532
             ->where($dayWhere)
524 533
             ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
534
+            ->whereNotIn('user_id',$testUids)
525 535
             ->sum('number'); // 共富会员专区今日总业绩
526 536
 
527 537
         $data[] = ['className' => 'el-icon-s-goods', 'count' => $sharedUserCount, 'name' => '共富会员总人数'];

+ 3 - 2
app/common/repositories/store/StoreCategoryRepository.php

@@ -92,9 +92,10 @@ class StoreCategoryRepository extends BaseRepository
92 92
      * @Date: 2020/5/16
93 93
      * @return mixed
94 94
      */
95
-    public function getList()
95
+    public function getList($merId)
96 96
     {
97
-        $menus = $this->dao->getAllOptions(0);
97
+        //$menus = $this->dao->getAllOptions(0);取消硬编码
98
+        $menus = $this->dao->getAllOptions($merId);
98 99
         $menus = formatCascaderData($menus, 'cate_name', 3);
99 100
         return $menus;
100 101
     }

+ 5 - 0
app/common/repositories/store/order/StoreCartRepository.php

@@ -166,4 +166,9 @@ class StoreCartRepository extends BaseRepository
166 166
     {
167 167
         return $this->dao->getCartEntityListByUidAndProductIdListAndIsPay($uid, $productIdList);
168 168
     }
169
+
170
+    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
171
+    {
172
+        return $this->dao->getCartEntityListByUidAndProductIdList($uid, $productIdList);
173
+    }
169 174
 }

+ 130 - 98
app/common/repositories/store/order/StoreOrderRepository.php

@@ -86,6 +86,7 @@ use app\common\repositories\user\UserSignHongbaoRepository;
86 86
 use app\common\repositories\user\UserSignJingdouRepository;
87 87
 use app\common\repositories\user\UserSignScoreRepository;
88 88
 use app\common\repositories\user\UserSignVrRepository;
89
+use app\common\repositories\user\UserSignXfbRepository;
89 90
 use app\common\repositories\user\UserThirdRepository;
90 91
 use app\common\repositories\user\UserWithdrawalLimitRecordRepository;
91 92
 use app\common\repositories\wechat\RoutineQrcodeRepository;
@@ -2387,7 +2388,7 @@ class StoreOrderRepository extends BaseRepository
2387 2388
                 }
2388 2389
             }
2389 2390
 
2390
-            $orderpri = $cartInfo['list'][$_k]['productAttr']['price'];
2391
+            $orderpri = bcmul($cartInfo['list'][$_k]['productAttr']['price'], $cartInfo['list'][$_k]['cart_num'], 2);
2391 2392
             //var_dump($ss);
2392 2393
             //支付组合
2393 2394
             $num_yl = 0;
@@ -2395,23 +2396,23 @@ class StoreOrderRepository extends BaseRepository
2395 2396
             $store_product_datas = Db::name('store_product')->where('product_id', $cart['product']['product_id'])->find();
2396 2397
             //var_dump($store_product_datas); ["product_id"]=>string(5) "15748" concession_pri
2397 2398
 
2398
-            if ($orderpri == '1180') {
2399
+            if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '1180') {
2399 2400
                 $num_yl = 1000;
2400
-            } else if ($orderpri == '10620') {
2401
+            } else if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '10620') {
2401 2402
                 $num_yl = 9000;
2402
-            } else if ($orderpri == '11800') {
2403
+            } else if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '11800') {
2403 2404
                 $num_yl = 10000;
2404
-            } else if ($orderpri == '2360') {
2405
+            } else if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '2360') {
2405 2406
                 $num_yl = 2000;
2406
-            } else if ($orderpri == '9440') {
2407
+            } else if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '9440') {
2407 2408
                 $num_yl = 8000;
2408
-            } else if ($orderpri == '5900') {
2409
+            } else if ($orderpri / $cartInfo['list'][$_k]['cart_num'] == '5900') {
2409 2410
                 $num_yl = 5000;
2410 2411
             }
2411 2412
 
2412 2413
             if ($store_product_datas['mer_id'] == 496) {
2413 2414
 
2414
-                $yanglao = bcmul($num_yl, 0.035, 2);//给预下订单中的商品展示 养老金 显示作用
2415
+                $yanglao = bcmul(bcmul($num_yl, 0.035, 2) , $cartInfo['list'][$_k]['cart_num'],2);//给预下订单中的商品展示 养老金 显示作用
2415 2416
                 $cartInfo['list'][$_k]['yanglao'] = $yanglao;
2416 2417
                 $pv = $num_yl;
2417 2418
                 //$v['vr']=$v['price'];
@@ -2468,7 +2469,8 @@ class StoreOrderRepository extends BaseRepository
2468 2469
                 $jf = $orderpri - bcmul($store_product_datas['concession_pri'], 0.3, 2) . ' + ' . bcmul($store_product_datas['concession_pri'], 0.3, 2);
2469 2470
                 $jd = $orderpri - bcmul($store_product_datas['concession_pri'], 0.35, 2) . ' + ' . bcmul($store_product_datas['concession_pri'], 0.35, 2);
2470 2471
                 if ($store_product_datas['concession_pri'] != null || $store_product_datas['concession_pri'] != 0) {
2471
-                    $yanglao = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2472
+                    $yanglao = bcmul(bcmul($store_product_datas['concession_pri'], 0.3, 2) , $cartInfo['list'][$_k]['cart_num'],2);
2473
+                    $cartInfo['list'][$_k]['yanglao'] = $yanglao;
2472 2474
                     $pv = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2473 2475
                     $srtArry['jfduihuan'] = $jf;
2474 2476
                     $srtArry['jdduihuan'] = $jd;
@@ -2476,11 +2478,11 @@ class StoreOrderRepository extends BaseRepository
2476 2478
                     $gongxian = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2477 2479
 
2478 2480
                     $jcvr = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.3, 2), 2);
2479
-                    $jcjf = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2481
+                    $jcjf = bcmul(bcmul($store_product_datas['concession_pri'], 0.3, 2) , $cartInfo['list'][$_k]['cart_num'],2);
2480 2482
                     $jcprice = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.3, 2), 2);
2481
-                    $jcjf1 = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2483
+                    $jcjf1 = bcmul(bcmul($store_product_datas['concession_pri'], 0.3, 2) , $cartInfo['list'][$_k]['cart_num'],2);
2482 2484
                     $jcvr1 = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.35, 2), 2);
2483
-                    $jcjd = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2485
+                    $jcjd = bcmul(bcmul($store_product_datas['concession_pri'], 0.35, 2), $cartInfo['list'][$_k]['cart_num'], 2);
2484 2486
                     $jcprice1 = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.35, 2), 2);
2485 2487
                     $jcjd1 = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2486 2488
 
@@ -2525,7 +2527,7 @@ class StoreOrderRepository extends BaseRepository
2525 2527
                 $pv = $productSku['plate_mer_profit'] ?? 0.00;
2526 2528
                 //复购区
2527 2529
                 // $pv = bcmul($orderpri, 0.3, 2);
2528
-                $yanglao = bcmul($pv, 0.5, 2);//给预下订单中的商品展示 养老金 显示作用
2530
+                $yanglao = bcmul(bcmul($pv, 0.5, 2) , $cartInfo['list'][$_k]['cart_num'],2);//给预下订单中的商品展示 养老金 显示作用
2529 2531
                 $cartInfo['list'][$_k]['pv'] = $pv;
2530 2532
                 $cartInfo['list'][$_k]['yanglao'] = $yanglao;
2531 2533
 
@@ -2543,7 +2545,7 @@ class StoreOrderRepository extends BaseRepository
2543 2545
                 $pvProportion = bcsub('1', bcdiv($sharedProsperityRecommendConfigEntityByMaxRewardRatio->getRewardRatio(), '100', 4), 2);
2544 2546
                 $pv = bcmul($productSku['plate_mer_profit'], $pvProportion, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
2545 2547
 
2546
-                $yanglao = bcmul($productSku['price'], CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], 2);
2548
+                $yanglao = bcmul(bcmul($productSku['price'], CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], 2), $cartInfo['list'][$_k]['cart_num'], 2);
2547 2549
                 $cartInfo['list'][$_k]['pv'] = $pv;
2548 2550
                 $cartInfo['list'][$_k]['yanglao'] = $yanglao;
2549 2551
 
@@ -2561,7 +2563,8 @@ class StoreOrderRepository extends BaseRepository
2561 2563
                     $jf = $orderpri - bcmul($store_product_datas['concession_pri'], 0.3, 2) . ' + ' . bcmul($store_product_datas['concession_pri'], 0.3, 2);
2562 2564
                     $jd = $orderpri - bcmul($store_product_datas['concession_pri'], 0.35, 2) . ' + ' . bcmul($store_product_datas['concession_pri'], 0.35, 2);
2563 2565
                     if ($store_product_datas['concession_pri'] != null || $store_product_datas['concession_pri'] != 0) {
2564
-                        $yanglao = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2566
+                        $yanglao = bcmul(bcmul($store_product_datas['concession_pri'], 0.3, 2), $cartInfo['list'][$_k]['cart_num'], 2);
2567
+                        $cartInfo['list'][$_k]['yanglao'] = $yanglao;
2565 2568
                         $pv = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2566 2569
                         $srtArry['jfduihuan'] = $jf;
2567 2570
                         $srtArry['jdduihuan'] = $jd;
@@ -2571,9 +2574,9 @@ class StoreOrderRepository extends BaseRepository
2571 2574
                         $jcvr = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.3, 2), 2);
2572 2575
                         $jcjf = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2573 2576
                         $jcprice = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.3, 2), 2);
2574
-                        $jcjf1 = bcmul($store_product_datas['concession_pri'], 0.3, 2);
2577
+                        $jcjf1 = bcmul(bcmul($store_product_datas['concession_pri'], 0.3, 2), $cartInfo['list'][$_k]['cart_num'], 2);
2575 2578
                         $jcvr1 = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.35, 2), 2);
2576
-                        $jcjd = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2579
+                        $jcjd = bcmul(bcmul($store_product_datas['concession_pri'], 0.35, 2), $cartInfo['list'][$_k]['cart_num'], 2);
2577 2580
                         $jcprice1 = bcsub($orderpri, bcmul($store_product_datas['concession_pri'], 0.35, 2), 2);
2578 2581
                         $jcjd1 = bcmul($store_product_datas['concession_pri'], 0.35, 2);
2579 2582
 
@@ -4016,14 +4019,14 @@ class StoreOrderRepository extends BaseRepository
4016 4019
                 $tuimark = "推荐消费获得养老金" . $tuiguanyanglaojin;
4017 4020
 
4018 4021
                 //end会费
4019
-                //sat存养老金
4020
-                $tuititle = "养老金 ";
4021
-                $commission_type = 5;
4022
-                if ($tuiguanyanglaojin >= 0.01) {
4023
-                    $this->add_bill($tuititle, $tuiguanyanglaojin, $sprerdUser["uid"], $tuimark, $commission_type, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]);
4024
-                } else {
4025
-                    Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低,推荐养老金低于0.01无法入库 特此记录!']);
4026
-                }
4022
+                //sat存养老金 不发放推荐人养老金
4023
+                // $tuititle = "养老金 ";
4024
+                // $commission_type = 5;
4025
+                // if ($tuiguanyanglaojin >= 0.01) {
4026
+                //     $this->add_bill($tuititle, $tuiguanyanglaojin, $sprerdUser["uid"], $tuimark, $commission_type, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]);
4027
+                // } else {
4028
+                //     Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低,推荐养老金低于0.01无法入库 特此记录!']);
4029
+                // }
4027 4030
 
4028 4031
             }
4029 4032
 
@@ -9980,7 +9983,7 @@ class StoreOrderRepository extends BaseRepository
9980 9983
                         // //推广佣金
9981 9984
                         $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
9982 9985
                         //养老金
9983
-                        $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
9986
+                        // $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . bcmul($pv, 0.05, 2), $store_order_data['mer_id'], 0);
9984 9987
                         // 1123 用户分享的商品不得分享佣金 先暂时这样写
9985 9988
                         if($store_order_data['share_uid'] && $store_order_data['share_uid'] != 1123){
9986 9989
                             $this->bill_user_log($store_order_data['share_uid'], bcmul($pv * 0.9, 0.03, 2), $store_order_data['order_id'], 20, $store_order_data['order_sn'], '分享获得佣金', $store_order_data['mer_id'], 0);
@@ -10077,7 +10080,7 @@ class StoreOrderRepository extends BaseRepository
10077 10080
                 $this->con_log($spread_data['uid'], round($gx_jf, 2), $store_order_data['order_id'], 0, "推广会员专区商品赠送贡献值", 1);
10078 10081
 
10079 10082
                 //养老金
10080
-                $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
10083
+                // $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.035, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '消费获得养老金' . round($pv * 0.035, 2), $store_order_data['mer_id']);
10081 10084
                 //佣金
10082 10085
                 $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id']);
10083 10086
                 //复购金
@@ -10206,7 +10209,7 @@ class StoreOrderRepository extends BaseRepository
10206 10209
                         //推广佣金
10207 10210
                         $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $store_order_data['order_sn'], '推广获得佣金', $store_order_data['mer_id'], 0);
10208 10211
                         //养老金
10209
-                        $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
10212
+                        // $this->bill_user_log($spread_data['uid'], bcmul($pv, 0.05, 2), $store_order_data['order_id'], 5, $store_order_data['order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
10210 10213
                     }
10211 10214
 
10212 10215
                     //普通用户推广人
@@ -11313,24 +11316,24 @@ class StoreOrderRepository extends BaseRepository
11313 11316
                     );
11314 11317
 
11315 11318
                     // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11316
-                    if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11317
-                        $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11318
-                        /** @var UserBillRepository $userBillRepository */
11319
-                        $userBillRepository = app()->make(UserBillRepository::class);
11320
-                        $userBillRepository->addUserBill(
11321
-                            $userEntityBySpreadUid->getUid(),
11322
-                            UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11323
-                            UserBillEnum::PM['INCOME']['code'],
11324
-                            $yanglaojinBySpreadUid,
11325
-                            UserBillEnum::CATEGORY['NowMoney']['code'],
11326
-                            UserBillEnum::TYPE['Commission']['code'],
11327
-                            UserBillEnum::SOURCE['ONLINE']['code'],
11328
-                            UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11329
-                            UserBillEnum::TYPE_SHOP['Platform']['code'],
11330
-                            $storeOrderEntity->getOrderId(),
11331
-                            '推广精彩生活区商品获得养老金'
11332
-                        );
11333
-                    }
11319
+                    // if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11320
+                    //     $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['WonderfulLiving']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11321
+                    //     /** @var UserBillRepository $userBillRepository */
11322
+                    //     $userBillRepository = app()->make(UserBillRepository::class);
11323
+                    //     $userBillRepository->addUserBill(
11324
+                    //         $userEntityBySpreadUid->getUid(),
11325
+                    //         UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11326
+                    //         UserBillEnum::PM['INCOME']['code'],
11327
+                    //         $yanglaojinBySpreadUid,
11328
+                    //         UserBillEnum::CATEGORY['NowMoney']['code'],
11329
+                    //         UserBillEnum::TYPE['Commission']['code'],
11330
+                    //         UserBillEnum::SOURCE['ONLINE']['code'],
11331
+                    //         UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11332
+                    //         UserBillEnum::TYPE_SHOP['Platform']['code'],
11333
+                    //         $storeOrderEntity->getOrderId(),
11334
+                    //         '推广精彩生活区商品获得养老金'
11335
+                    //     );
11336
+                    // }
11334 11337
                 }
11335 11338
             }
11336 11339
 
@@ -11558,24 +11561,24 @@ class StoreOrderRepository extends BaseRepository
11558 11561
                         );
11559 11562
 
11560 11563
                         // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11561
-                        if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11562
-                            $yanglaojinBySpreadUid = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11563
-                            /** @var UserBillRepository $userBillRepository */
11564
-                            $userBillRepository = app()->make(UserBillRepository::class);
11565
-                            $userBillRepository->addUserBill(
11566
-                                $userEntityBySpreadUid->getUid(),
11567
-                                UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11568
-                                UserBillEnum::PM['INCOME']['code'],
11569
-                                $yanglaojinBySpreadUid,
11570
-                                UserBillEnum::CATEGORY['NowMoney']['code'],
11571
-                                UserBillEnum::TYPE['Commission']['code'],
11572
-                                UserBillEnum::SOURCE['ONLINE']['code'],
11573
-                                UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11574
-                                UserBillEnum::TYPE_SHOP['Platform']['code'],
11575
-                                $storeOrderEntity->getOrderId(),
11576
-                                '推广会员专区商品获得养老金'
11577
-                            );
11578
-                        }
11564
+                        // if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11565
+                        //     $yanglaojinBySpreadUid = bcmul($basePrice, CommonEnum::ORDER_EARNING_ALLOCATION['MemberZone']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11566
+                        //     /** @var UserBillRepository $userBillRepository */
11567
+                        //     $userBillRepository = app()->make(UserBillRepository::class);
11568
+                        //     $userBillRepository->addUserBill(
11569
+                        //         $userEntityBySpreadUid->getUid(),
11570
+                        //         UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11571
+                        //         UserBillEnum::PM['INCOME']['code'],
11572
+                        //         $yanglaojinBySpreadUid,
11573
+                        //         UserBillEnum::CATEGORY['NowMoney']['code'],
11574
+                        //         UserBillEnum::TYPE['Commission']['code'],
11575
+                        //         UserBillEnum::SOURCE['ONLINE']['code'],
11576
+                        //         UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11577
+                        //         UserBillEnum::TYPE_SHOP['Platform']['code'],
11578
+                        //         $storeOrderEntity->getOrderId(),
11579
+                        //         '推广会员专区商品获得养老金'
11580
+                        //     );
11581
+                        // }
11579 11582
                     }
11580 11583
                 }
11581 11584
             }
@@ -11733,27 +11736,50 @@ class StoreOrderRepository extends BaseRepository
11733 11736
                 '购买共富区商品获得PV'
11734 11737
             );
11735 11738
 
11739
+            // 特定商品发放幸福币
11740
+            /** @var StoreCartRepository $storeCartRepository */
11741
+            $storeCartRepository = app()->make(StoreCartRepository::class);
11742
+            $storeCartEntity = $storeCartRepository->getCartEntityListByUidAndProductIdList($storeOrderEntity->getUid(), [90619]);
11743
+            if (!empty($storeCartEntityList)) {
11744
+                $xfbData = [
11745
+                    'uid' => $sharedProsperityUserEntity->getUserId(),
11746
+                    'before' => 0,
11747
+                    'number' => $storeOrderEntity->getPayPrice(),
11748
+                    'after' => 0,
11749
+                    'mark' => '购买共富区商品获得幸福币:' . $storeOrderEntity->getPayPrice(),
11750
+                    'desc' => '购买共富区商品获得幸福币',
11751
+                    'order_sn' => $storeOrderEntity->getOrderSn(),
11752
+                    'order_type' => $storeOrderEntity->getOrderType(),
11753
+                    'type' => 1,
11754
+                    'addtime' => time()
11755
+                ];
11756
+            }
11757
+            /** @var UserSignXfbRepository $xfbRepository */
11758
+            $xfbRepository = app()->make(UserSignXfbRepository::class);
11759
+            $xfbRepository->create($xfbData);
11760
+
11761
+
11736 11762
             if (!empty($sharedProsperityUserEntity->getParentId())) {
11737 11763
                 // 如果 共富区推荐人 不是平台,则为 推荐人发放 推荐奖励
11738 11764
                 $sharedProsperityUserEntityByParent = $sharedProsperityUserRepository->getSharedProsperityUserEntityByUserId($sharedProsperityUserEntity->getParentId());
11739 11765
                 if (!empty($sharedProsperityUserEntityByParent->getId())) {
11740 11766
                     // 为 共富体系推荐人 发放养老金
11741
-                    $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11742
-                    /** @var UserBillRepository $userBillRepository */
11743
-                    $userBillRepository = app()->make(UserBillRepository::class);
11744
-                    $userBillRepository->addUserBill(
11745
-                        $sharedProsperityUserEntityByParent->getUserId(),
11746
-                        UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11747
-                        UserBillEnum::PM['INCOME']['code'],
11748
-                        $yanglaojinBySpreadUid,
11749
-                        UserBillEnum::CATEGORY['NowMoney']['code'],
11750
-                        UserBillEnum::TYPE['Commission']['code'],
11751
-                        UserBillEnum::SOURCE['ONLINE']['code'],
11752
-                        UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11753
-                        UserBillEnum::TYPE_SHOP['Platform']['code'],
11754
-                        $storeOrderEntity->getOrderId(),
11755
-                        '推广共富区会员消费获得养老金'
11756
-                    );
11767
+                    // $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11768
+                    // /** @var UserBillRepository $userBillRepository */
11769
+                    // $userBillRepository = app()->make(UserBillRepository::class);
11770
+                    // $userBillRepository->addUserBill(
11771
+                    //     $sharedProsperityUserEntityByParent->getUserId(),
11772
+                    //     UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11773
+                    //     UserBillEnum::PM['INCOME']['code'],
11774
+                    //     $yanglaojinBySpreadUid,
11775
+                    //     UserBillEnum::CATEGORY['NowMoney']['code'],
11776
+                    //     UserBillEnum::TYPE['Commission']['code'],
11777
+                    //     UserBillEnum::SOURCE['ONLINE']['code'],
11778
+                    //     UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11779
+                    //     UserBillEnum::TYPE_SHOP['Platform']['code'],
11780
+                    //     $storeOrderEntity->getOrderId(),
11781
+                    //     '推广共富区会员消费获得养老金'
11782
+                    // );
11757 11783
 
11758 11784
                     // 发放消费股
11759 11785
                     $consumerStocksBySpread = bcmul($storeOrderEntity->getTotalPrice(), CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Spread']['ConsumerStocks']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
@@ -11975,24 +12001,24 @@ class StoreOrderRepository extends BaseRepository
11975 12001
                     );
11976 12002
 
11977 12003
                     // 如果用户的身份 不是 普通用户 (高于普通用户) 则发放养老金
11978
-                    if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
11979
-                        $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11980
-                        /** @var UserBillRepository $userBillRepository */
11981
-                        $userBillRepository = app()->make(UserBillRepository::class);
11982
-                        $userBillRepository->addUserBill(
11983
-                            $userEntityBySpreadUid->getUid(),
11984
-                            UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11985
-                            UserBillEnum::PM['INCOME']['code'],
11986
-                            $yanglaojinBySpreadUid,
11987
-                            UserBillEnum::CATEGORY['NowMoney']['code'],
11988
-                            UserBillEnum::TYPE['Commission']['code'],
11989
-                            UserBillEnum::SOURCE['ONLINE']['code'],
11990
-                            UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
11991
-                            UserBillEnum::TYPE_SHOP['Platform']['code'],
11992
-                            $storeOrderEntity->getOrderId(),
11993
-                            '推广商贸区商品获得养老金'
11994
-                        );
11995
-                    }
12004
+                    // if ($userEntityBySpreadUid->getUserGroup() != CommonEnum::USER_GROUP['RegularUser']['code']) {
12005
+                    //     $yanglaojinBySpreadUid = bcmul($storeOrderEntity->getConPri(), CommonEnum::ORDER_EARNING_ALLOCATION['CommercialDistrict']['Spread']['YangLaoJin']['Ratio']['code'], CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
12006
+                    //     /** @var UserBillRepository $userBillRepository */
12007
+                    //     $userBillRepository = app()->make(UserBillRepository::class);
12008
+                    //     $userBillRepository->addUserBill(
12009
+                    //         $userEntityBySpreadUid->getUid(),
12010
+                    //         UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
12011
+                    //         UserBillEnum::PM['INCOME']['code'],
12012
+                    //         $yanglaojinBySpreadUid,
12013
+                    //         UserBillEnum::CATEGORY['NowMoney']['code'],
12014
+                    //         UserBillEnum::TYPE['Commission']['code'],
12015
+                    //         UserBillEnum::SOURCE['ONLINE']['code'],
12016
+                    //         UserBillEnum::ORDER_TYPE['SELF_OPERATED']['code'],
12017
+                    //         UserBillEnum::TYPE_SHOP['Platform']['code'],
12018
+                    //         $storeOrderEntity->getOrderId(),
12019
+                    //         '推广商贸区商品获得养老金'
12020
+                    //     );
12021
+                    // }
11996 12022
                 }
11997 12023
             }
11998 12024
 
@@ -12208,6 +12234,12 @@ class StoreOrderRepository extends BaseRepository
12208 12234
                     }, $userWithdrawalLimitRecordEntityList);
12209 12235
                     $userWithdrawalLimitRecordRepository->executeByIdList($userWithdrawalLimitRecordIdList);
12210 12236
                 }
12237
+
12238
+                // 结算幸福币
12239
+                /** @var UserSignXfbRepository $xfbRepository */
12240
+                $xfbRepository = app()->make(UserSignXfbRepository::class);
12241
+                // 结算
12242
+                $xfbRepository->settlement($unsettledOrderSnList);
12211 12243
             } catch (DbException $e) {
12212 12244
                 throw new ValidateException('订单结算失败');
12213 12245
             }

+ 4 - 1
app/common/repositories/store/product/ProductRepository.php

@@ -1239,7 +1239,7 @@ class ProductRepository extends BaseRepository
1239 1239
                 'ot_price' => set_price_rtrim($value['ot_price']),
1240 1240
                 'unique'   => $value['unique'],
1241 1241
                 'dacang'   => $value['dacang_price'] ? set_price_rtrim($value['dacang_price']) : 'null',
1242
-                'is_usable' => $value['is_usable'],
1242
+                'is_usable' => $value['is_usable'],//是否启用
1243 1243
             ];
1244 1244
             if ($productType) {
1245 1245
                 $sku[$value['sku']]['stock'] = $value['stock'] - $make->seckillSkuOrderCounut($value['unique']); //获取sku的销量
@@ -1849,6 +1849,9 @@ class ProductRepository extends BaseRepository
1849 1849
                         3=>$product['price']//复购金
1850 1850
                     ]
1851 1851
                 ];
1852
+            } else if($product['mer_id'] == 3447){
1853
+                $productSku = Db::name('store_product_attr_value')->where('product_id', $good_id)->order('price asc')->find();
1854
+                $yanglao = bcmul($productSku['price'], CommonEnum::ORDER_EARNING_ALLOCATION['SharedProsperity']['Self']['YangLaoJin']['Ratio']['code'], 2);
1852 1855
             } else {
1853 1856
                 // 商贸区
1854 1857
                 /** @var MerchantRepository $merchant */

+ 49 - 0
app/common/repositories/user/UserSignXfbRepository.php

@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+namespace app\common\repositories\user;
4
+
5
+use app\common\dao\user\UserDao;
6
+use app\common\dao\user\UserSignVrDao;
7
+use app\common\enum\user\UserSignVrEnum;
8
+use app\common\repositories\BaseRepository;
9
+use app\common\repositories\store\order\StoreOrderRepository;
10
+use app\entity\data\user\UserEntity;
11
+use app\entity\data\user\UserSignVrEntity;
12
+use think\db\exception\DbException;
13
+use think\exception\ValidateException;
14
+
15
+class UserSignXfbRepository extends BaseRepository
16
+{
17
+    public function __construct(UserSignVrDao $dao)
18
+    {
19
+        $this->dao = $dao;
20
+    }
21
+
22
+    public function create($data)
23
+    {
24
+        return $this->dao->create($data);
25
+    }
26
+
27
+    // 结算
28
+    public function settlement($orderSn)
29
+    {
30
+        foreach ($orderSn as $item) {
31
+            // 日志模型
32
+            $logModel = $this->dao->getWhere(['order_sn' => $item]);
33
+            // 用户模型
34
+            $userDao = new UserDao();
35
+            $userModel = $userDao->getWhere(['uid'=>$logModel->uid]);
36
+
37
+            // 修改日志表字段
38
+            $logModel->before = $userModel->xfb;
39
+            $logModel->after = $userModel->xfb + $logModel->number;;
40
+            $logModel->settlement_time = date('Y-m-d H:i:s');
41
+            $logModel->save();
42
+
43
+            // 修改用户表字段
44
+            $userModel->xfb = $userModel->xfb + $logModel->number;
45
+            $userModel->save();
46
+        }
47
+    }
48
+
49
+}

+ 1 - 1
app/controller/admin/Common.php

@@ -170,7 +170,7 @@ class Common extends BaseController
170 170
         $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
171 171
 
172 172
         //线上订单
173
-        $todayShangCount = Db::name('store_order')->where($dayWhere)->where('paid', 1)->count();
173
+        $todayShangCount = Db::name('store_order')->where($dayWhere)->where('paid', 1)->where('test_order', 0)->count();
174 174
 
175 175
         //线下订单
176 176
         $todayXiaCount = Db::name('order_merchant')->where($dayWhere)->where('paid', 1)->count();

+ 2 - 1
app/controller/admin/store/StoreCategory.php

@@ -187,7 +187,8 @@ class StoreCategory extends BaseController
187 187
      */
188 188
     public function getList()
189 189
     {
190
-        return app('json')->success($this->repository->getList());
190
+        $merId = $this->request->merId();
191
+        return app('json')->success($this->repository->getList($merId));
191 192
     }
192 193
 
193 194
     /**

+ 1 - 1
app/controller/api/Auth.php

@@ -636,7 +636,7 @@ class Auth extends BaseController
636 636
         if (!$spread_user) {
637 637
             return app('json')->fail('推荐人手机号不存在');
638 638
         }
639
-        if(empty($data['uid'])==$user['uid']){
639
+        if ($data['uid'] == $user['uid']) {
640 640
             return app('json')->fail('不能绑定自己为推荐人');
641 641
         }
642 642
 

+ 98 - 50
app/controller/api/Test.php

@@ -4,8 +4,11 @@ namespace app\controller\api;
4 4
 
5 5
 use app\common\dao\shared\SharedProsperityUserDao;
6 6
 use app\common\enum\CommonEnum;
7
+use app\common\enum\shared\SharedProsperityRewardRecordEnum;
7 8
 use app\common\model\shared\SharedProsperityUser;
8 9
 use app\common\repositories\shared\SharedProsperityUserRepository;
10
+use app\common\repositories\store\order\StoreGroupOrderRepository;
11
+use app\common\repositories\store\order\StoreOrderRepository;
9 12
 use app\common\repositories\user\UserRepository;
10 13
 use app\traits\GzcApiRequest;
11 14
 use think\facade\Db;
@@ -16,58 +19,103 @@ class Test
16 19
     {
17 20
 
18 21
 
19
-        $title = '系统补贴';
20
-        $map = [
21
-            294 => 165,
22
-            186 => 860
23
-        ];
22
+        // // 1、获取订单数据
23
+        // /** @var StoreGroupOrderRepository $storeGroupOrderRepository */
24
+        // $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
25
+        // // 获取订单组数据
26
+        // $groupOrderSn = 'wx177442719463317087';
27
+        // $storeGroupOrderEntity = $storeGroupOrderRepository->getStoreGroupOrderEntityByGroupOrderSn($groupOrderSn);
28
+        // /** @var StoreOrderRepository $storeOrderRepository */
29
+        // $storeOrderRepository = app()->make(StoreOrderRepository::class);
30
+        // // 获取订单集合
31
+        // $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
32
+        // try {
33
+        //     Db::transaction(function () use (
34
+        //         $storeGroupOrderRepository,
35
+        //         $storeGroupOrderEntity
36
+        //     ) {
37
+        //         $storeGroupOrderRepository->storeGroupOrderPaySuccess($storeGroupOrderEntity->getGroupOrderId());
38
+        //     });
39
+        // } catch (\Throwable $e) {
40
+        //     Db::name("log")
41
+        //         ->insert([
42
+        //             'data' => '【订单支付回调】【结算订单失败】:时间:' . date('Y-m-d H:i:s', time()) . ';订单编号:1111订单失败原因:' . json_encode([
43
+        //                     'error_message' => $e->getMessage(),
44
+        //                     'error_file' => $e->getFile(),
45
+        //                     'error_line' => $e->getLine(),
46
+        //                     'error_code' => $e->getCode(),
47
+        //                     'exception_class' => get_class($e),
48
+        //                     'trace' => $e->getTraceAsString()
49
+        //                 ], JSON_UNESCAPED_UNICODE)
50
+        //         ]);
51
+        //     dd($e->getMessage());
52
+        // }
53
+        //
54
+        //
55
+        // die;
56
+
57
+        //
58
+        // $title = '系统补贴';
59
+        // $map = [
60
+        //     294 => 165,
61
+        //     186 => 860
62
+        // ];
63
+        //
64
+        // foreach ($map as $uid => $money) {
65
+        //     $bill = [
66
+        //         'uid' => $uid,
67
+        //         'link_id' => 0,
68
+        //         'pm' => 1,
69
+        //         'title' => $title,
70
+        //         'category' => 'now_money',
71
+        //         'type' => 'commission',
72
+        //         'number' => $money,
73
+        //         'balance' => 0,
74
+        //         'mark' => $title,
75
+        //         'create_time' => date('Y-m-d H:i:s'),
76
+        //         'status' => 1,
77
+        //         'commission_type' => CommonEnum::COMMISSION_TYPE['SYSTEM_SUBSIDY_COMMISSION']['code'],
78
+        //         'order_sn' => 0,
79
+        //         'tripartite' => 0,
80
+        //         'type_shop' => 0,
81
+        //         'mer_id' => 0,
82
+        //         'source' => 0,
83
+        //         'order_type' => 1,
84
+        //         'is_red_brokerage' => 0,
85
+        //         'gzc' => 3,
86
+        //         'take_time' => time(),
87
+        //         'district_id' => '',
88
+        //         'street_id' => '',
89
+        //         'month' => '',
90
+        //     ];
91
+        //     $a = Db::name('user_bill')->insert($bill);
92
+        //
93
+        //     $b = Db::name('user')->where('uid', $uid)->inc('brokerage_price', $money)->update();
94
+        // }
95
+        // die;
24 96
 
25
-        foreach ($map as $uid => $money) {
26
-            $bill = [
27
-                'uid' => $uid,
28
-                'link_id' => 0,
29
-                'pm' => 1,
30
-                'title' => $title,
31
-                'category' => 'now_money',
32
-                'type' => 'commission',
33
-                'number' => $money,
34
-                'balance' => 0,
35
-                'mark' => $title,
36
-                'create_time' => date('Y-m-d H:i:s'),
37
-                'status' => 1,
38
-                'commission_type' => CommonEnum::COMMISSION_TYPE['SYSTEM_SUBSIDY_COMMISSION']['code'],
39
-                'order_sn' => 0,
40
-                'tripartite' => 0,
41
-                'type_shop' => 0,
42
-                'mer_id' => 0,
43
-                'source' => 0,
44
-                'order_type' => 1,
45
-                'is_red_brokerage' => 0,
46
-                'gzc' => 3,
47
-                'take_time' => time(),
48
-                'district_id' => '',
49
-                'street_id' => '',
50
-                'month' => '',
51
-            ];
52
-            $a = Db::name('user_bill')->insert($bill);
53 97
 
54
-            $b = Db::name('user')->where('uid', $uid)->inc('brokerage_price', $money)->update();
55
-        }
56
-        die;
98
+        // $sharedUserPvCount = Db::name('shared_prosperity_reward_record')
99
+        //     ->where(['type' => SharedProsperityRewardRecordEnum::TYPE['PV']['code'], 'status' => SharedProsperityRewardRecordEnum::STATUS['VALID']['code'], 'pm' => SharedProsperityRewardRecordEnum::PM['INCOME']['code']])
100
+        //     ->whereNotIn('user_id',$testUids)
101
+        //     ->sum('number'); // 共富会员专区总业绩
102
+        // dd($sharedUserPvCount);
103
+        // die;
57 104
 
58
-        $total = 8497.13;
105
+        //
106
+        $total = 2756.48;
59 107
         $map = [
60 108
             1 => 0.3,
61 109
             2 => 0.15,
62 110
             3 => 0.03,
63
-            4 => 0.008,
111
+            4 => 0.015,
64 112
         ];
65 113
         $groupMap = [
66
-            1 => 0.05,
67
-            2 => 0.1
114
+            1 => 0.1,
115
+            2 => 0.2
68 116
         ];
69
-
70
-        $users = Db::name('shared_prosperity_user')->group('partner_level')->field('partner_level,count(*) as num')->select()->toArray();
117
+        $testUids = Db::name('user')->where('test_user',  '1')->column('uid');
118
+        $users = Db::name('shared_prosperity_user')->whereNotIn('user_id',$testUids)->group('partner_level')->field('partner_level,count(*) as num')->select()->toArray();
71 119
 
72 120
         $res = [];
73 121
         foreach ($users as $user) {
@@ -81,7 +129,7 @@ class Test
81 129
         }
82 130
 
83 131
         $groupRes = [];
84
-        $groupUsers = Db::name('shared_prosperity_group_user')->group('group_id')->field('group_id,count(*)as num')->select()->toArray();
132
+        $groupUsers = Db::name('shared_prosperity_group_user')->whereNotIn('user_id',$testUids)->group('group_id')->field('group_id,count(*)as num')->select()->toArray();
85 133
         foreach ($groupUsers as $groupUser) {
86 134
             $groupRes[$groupUser['group_id']] = [
87 135
                 'num' => $groupUser['num'],
@@ -120,14 +168,14 @@ class Test
120 168
         // dd($res);
121 169
 
122 170
 
123
-        // /** @var SharedProsperityUserRepository $userRepository */
124
-        // $userRepository = app()->make(SharedProsperityUserRepository::class);
125
-        // $list = $userRepository->getUserTree(2393);
171
+        /** @var SharedProsperityUserRepository $userRepository */
172
+        $userRepository = app()->make(SharedProsperityUserRepository::class);
173
+        $list = $userRepository->getUserTree(294);
126 174
         // var_dump(json_encode($list));
127
-        $field = request()->param('field');
128
-        /** @var UserRepository $userRepository */
129
-        $userRepository = app()->make(UserRepository::class);
130
-        $list = $userRepository->getUserForTree($field, 0);
175
+        // $field = request()->param('field');
176
+        // /** @var UserRepository $userRepository */
177
+        // $userRepository = app()->make(UserRepository::class);
178
+        // $list = $userRepository->getUserForTree($field, 0);
131 179
         var_dump(json_encode($list));
132 180
         // return app('json')->success($list);
133 181
     }

+ 34 - 17
app/controller/api/shareProsperity/Task.php

@@ -456,16 +456,33 @@ class Task
456 456
         // 徐丽萍168元,
457 457
         // 李玉芝 268元,
458 458
         // 其他5人,每人68元
459
+        // $userData = [
460
+        //     192 => 880,
461
+        //     62 => 490,
462
+        //     43 => 168,
463
+        //     2393 => 268,
464
+        //     3 => 68,
465
+        //     4001 => 68,
466
+        //     4073 => 68,
467
+        //     2540 => 68,
468
+        //     4899 => 68,
469
+        // ];
470
+        // 2026-3-23总裁分红
471
+        // 刘银霞1280元,
472
+        // 李素红380元,
473
+        // 徐丽萍158元,
474
+        // 李玉芝 238元,
475
+        // 其他5人,每人68元
459 476
         $userData = [
460
-            192 => 880,
461
-            62 => 490,
462
-            43 => 168,
463
-            2393 => 268,
464
-            3 => 68,
465
-            4001 => 68,
466
-            4073 => 68,
467
-            2540 => 68,
468
-            4899 => 68,
477
+            192 => 1280,
478
+            62 => 380,
479
+            43 => 158,
480
+            2393 => 238,
481
+            3 => 58,
482
+            4001 => 58,
483
+            4073 => 58,
484
+            2540 => 58,
485
+            4899 => 58,
469 486
         ];
470 487
 
471 488
         foreach ($userData as $uid => $money) {
@@ -506,11 +523,11 @@ class Task
506 523
         $groupId = 1;
507 524
         $desc = [
508 525
             1 => '共富万人团分红',
509
-            2 => '共富千人团分红'
526
+            2 => '共富开创合伙人分红'
510 527
         ];
511 528
         $money = [
512
-            1 => 2.41,
513
-            2 => 23.37
529
+            1 => 1.78,
530
+            2 => 17.22
514 531
         ];
515 532
 
516 533
         $groupUser = Db::name('shared_prosperity_group_user')->where('group_id', $groupId)->where('status',1)->select()->toArray();
@@ -560,10 +577,10 @@ class Task
560 577
             4 => '共富钻石合伙人分红',
561 578
         ];
562 579
         $money = [
563
-            1 => 5.05,
564
-            2 => 11.81,
565
-            3 => 24.93,
566
-            4 => 29.92,
580
+            1 => 1.77,
581
+            2 => 4.3,
582
+            3 => 6.89,
583
+            4 => 20.67,
567 584
         ];
568 585
         $groupUser = Db::name('shared_prosperity_user')->where('partner_level', $level)->select()->toArray();
569 586
         $userData = array_column($groupUser, 'user_id');
@@ -605,7 +622,7 @@ class Task
605 622
     {
606 623
         $title = '系统补贴';
607 624
         $map = [
608
-            186 => 680
625
+            186 => 380
609 626
         ];
610 627
 
611 628
         foreach ($map as $uid => $money) {

+ 1 - 1
app/controller/api/store/order/StoreOrder.php

@@ -1179,7 +1179,7 @@ class StoreOrder extends BaseController
1179 1179
             return app('json')->fail('订单未发货');
1180 1180
         $merchantRepository = app()->make(MerchantRepository::class);
1181 1181
         $order['mer_service_phone'] = $merchantRepository->get($order['mer_id'])['mer_phone'] ?? '';
1182
-        $express = ExpressService::express($order->delivery_id);
1182
+        $express = ExpressService::express($order->delivery_id,$order->delivery_type);
1183 1183
         $order->append(['orderProduct']);
1184 1184
         return app('json')->success(compact('express', 'order'));
1185 1185
     }

+ 25 - 0
app/controller/api/user/User.php

@@ -616,6 +616,31 @@ class User extends BaseController
616 616
     }
617 617
 
618 618
 
619
+    /**
620
+     * @return mixed
621
+     * @throws \think\db\exception\DataNotFoundException
622
+     * @throws \think\db\exception\DbException
623
+     * @throws \think\db\exception\ModelNotFoundException
624
+     * @author 史晨
625
+     * @date 2026/4/9 14:16
626
+     * 幸福币列表
627
+     */
628
+    public function xfb_list()
629
+    {
630
+        $type = $this->request->param('type');
631
+        if (!$type) {
632
+            return app('json')->fail('参数错误');
633
+        }
634
+        [$page, $limit] = $this->getPage();
635
+        $uid = $this->request->uid();
636
+        $where['uid'] = $uid;
637
+        $list = DB::name('user_sign_xfb')->where($where)->where('type', $type)->page($page, $limit)->order("id desc")->select();
638
+        $obtain = Db::name('user_sign_xfb')->where($where)->where('type', 1)->sum('number');
639
+        $consume = Db::name('user_sign_xfb')->where($where)->where('type', 2)->sum('number');
640
+        return app("json")->success(['list' => $list, 'obtain' => $obtain, 'consume' => $consume]);
641
+    }
642
+
643
+
619 644
     public function spread_info_yhc()
620 645
     {
621 646
         log::info("============ddddddddd");

+ 1 - 0
config/console.php

@@ -37,5 +37,6 @@ return [
37 37
         'sharedPartnerConsumeUpdate' => 'app\command\SharedPartnerConsumeUpdate',
38 38
         'productPriceUpdate' => 'app\command\ProductPriceUpdate',
39 39
         'deleteApiLog' => 'app\command\DeleteApiLog',
40
+        'sharedOfflineOrderProfitDelete' => 'app\command\SharedOfflineOrderProfitDelete',
40 41
     ],
41 42
 ];

+ 5 - 1
crmeb/services/ExpressService.php

@@ -25,8 +25,12 @@ class ExpressService
25 25
         return json_decode($res, true) ?: null;
26 26
     }
27 27
 
28
-    public static function express($delivery_id)
28
+    public static function express($delivery_id, $delivery_type = 1)
29 29
     {
30
+        // 虚拟发货不返回物流信息
31
+        if ($delivery_type == 3) {
32
+            return [];
33
+        }
30 34
         if (Cache::has('express_' . $delivery_id)) {
31 35
             $result = Cache::get('express_' . $delivery_id);
32 36
         } else {

+ 2 - 1
crmeb/traits/CategoresDao.php

@@ -224,7 +224,8 @@ trait CategoresDao
224 224
     {
225 225
         $field = $this->getParentId().',cate_name';
226 226
         return ($this->getModel()::getDB())->when(($mer_id !== null),function($query)use($mer_id){
227
-            $query->where('mer_id', $mer_id);
227
+            $query->whereIn('mer_id', ['0', $mer_id]);//加上原本0的商品分类
228
+//            $query->where('mer_id', $mer_id);
228 229
         })->when($status,function($query)use($status){
229 230
             $query->where($this->getStatus(),$status);
230 231
         })->when(($level !== null),function($query)use($level){

+ 1 - 0
route/api.php

@@ -356,6 +356,7 @@ Route::group('api/', function () {
356 356
             Route::get('vr_name','User/vr_name');//VR名称
357 357
             Route::post('un_bind', 'User/unBindVxOrAli');//解绑微信或支付宝
358 358
 
359
+            Route::get('xfb_list','User/xfb_list');//购物金记录
359 360
         })->prefix('api.user.');
360 361
 
361 362
         // 共富区