|
|
@@ -10022,6 +10022,198 @@ class StoreOrderRepository extends BaseRepository
|
|
10022
|
10022
|
}
|
|
10023
|
10023
|
|
|
10024
|
10024
|
|
|
|
10025
|
+ } else {
|
|
|
10026
|
+ // 商贸区
|
|
|
10027
|
+ /** @var \app\common\repositories\merchant\MerchantRepository $merchant */
|
|
|
10028
|
+ $merchant = app()->make(MerchantRepository::class);
|
|
|
10029
|
+ $merchantInfo = $merchant->get($store_order_data['mer_id']);
|
|
|
10030
|
+ // 1企业2个体3个人
|
|
|
10031
|
+ if ($merchantInfo && !empty($store_order_data) && in_array($merchantInfo['type'],[2,3])) {
|
|
|
10032
|
+// $job_par = json_decode($store_order_data['fzone_paytype'], true);
|
|
|
10033
|
+
|
|
|
10034
|
+ //商家让利部分的拆分
|
|
|
10035
|
+ $ylj_pri = round($concession_pri * 0.3, 2); // 让利部分30%给消费者做养老金
|
|
|
10036
|
+ $pv = round($concession_pri * 0.35, 2); // 35%做业绩PV分配
|
|
|
10037
|
+
|
|
|
10038
|
+ //分配养老金给消费者
|
|
|
10039
|
+ $ylj_amount_mine = $user_data['annuity'] + $ylj_pri;
|
|
|
10040
|
+ //分配积分和贡献值给消费者
|
|
|
10041
|
+ $con = $user_data['contribute'] + $pv;
|
|
|
10042
|
+ $score = $user_data['score'] + $pv;
|
|
|
10043
|
+
|
|
|
10044
|
+ // 让利部分30%给消费者做养老金{$ylj_pri}
|
|
|
10045
|
+ $this->bill_user_log($user_data['uid'], $ylj_pri, $store_order_data['order_id'], 5, $group_order['group_order_sn'], '消费获得养老金' . $ylj_pri, $store_order_data['mer_id'], 0);
|
|
|
10046
|
+ // 消费者购买商品赠送PV等值的积分和贡献值
|
|
|
10047
|
+ $this->con_log($user_data['uid'], $pv, $store_order_data['order_id'], 12, "购买商贸区商品赠送贡献值");
|
|
|
10048
|
+ $this->score_log($user_data['uid'], $pv, $store_order_data['order_id'], 12, "购买商贸区商品赠送积分");
|
|
|
10049
|
+
|
|
|
10050
|
+ // @todo ------------PV业绩100%分配如下------------------
|
|
|
10051
|
+ if ($user_data['spread_uid'] != 0) {
|
|
|
10052
|
+ //查询下单用户上级
|
|
|
10053
|
+ $spread_data = Db::name('user')->where('uid', $user_data['spread_uid'])->find();
|
|
|
10054
|
+
|
|
|
10055
|
+ //业务员或以上的推荐人等级
|
|
|
10056
|
+ //user_group=1是消费者 3%,2:业务员 5%,3:业务经理7%,4:初级合伙人9%,5:中级合伙人11%,6:高级合伙人13%,7:董事15%
|
|
|
10057
|
+ if ($spread_data['user_group'] > 1) {
|
|
|
10058
|
+
|
|
|
10059
|
+ // //给推广者分配佣金
|
|
|
10060
|
+ $yj_amount = 0;
|
|
|
10061
|
+ $ylj_amount = $spread_data['annuity'] + round($pv * 0.05, 2);
|
|
|
10062
|
+ $ssf = 0;//变量
|
|
|
10063
|
+ $yj_amount_90 = 0;//90%的佣金
|
|
|
10064
|
+
|
|
|
10065
|
+ if ($spread_data['user_group'] == 2) {
|
|
|
10066
|
+ $ssf = round($pv * 0.07, 2);
|
|
|
10067
|
+ $con = $spread_data['contribute'] + round($pv * 0.07, 2);
|
|
|
10068
|
+ $score = $spread_data['score'] + round($pv * 0.07, 2);
|
|
|
10069
|
+
|
|
|
10070
|
+
|
|
|
10071
|
+ $yj_amount_90 = round($pv * 0.07, 2) * 0.9;
|
|
|
10072
|
+ $fgj_amount_10 = round($pv * 0.07, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10073
|
+
|
|
|
10074
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10075
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10076
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10077
|
+
|
|
|
10078
|
+
|
|
|
10079
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10080
|
+ } else if ($spread_data['user_group'] == 3) {
|
|
|
10081
|
+ $ssf = round($pv * 0.09, 2);
|
|
|
10082
|
+ $con = $spread_data['contribute'] + round($pv * 0.09, 2);
|
|
|
10083
|
+ $score = $spread_data['score'] + round($pv * 0.09, 2);
|
|
|
10084
|
+
|
|
|
10085
|
+ $yj_amount_90 = round($pv * 0.09, 2) * 0.9;
|
|
|
10086
|
+ $fgj_amount_10 = round($pv * 0.09, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10087
|
+
|
|
|
10088
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10089
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10090
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10091
|
+
|
|
|
10092
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10093
|
+ } else if ($spread_data['user_group'] == 4) {
|
|
|
10094
|
+ $ssf = round($pv * 0.11, 2);
|
|
|
10095
|
+ $con = $spread_data['contribute'] + round($pv * 0.11, 2);
|
|
|
10096
|
+ $score = $spread_data['score'] + round($pv * 0.11, 2);
|
|
|
10097
|
+
|
|
|
10098
|
+ $yj_amount_90 = round($pv * 0.11, 2) * 0.9;
|
|
|
10099
|
+ $fgj_amount_10 = round($pv * 0.11, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10100
|
+
|
|
|
10101
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10102
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10103
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10104
|
+
|
|
|
10105
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10106
|
+ } else if ($spread_data['user_group'] == 5) {
|
|
|
10107
|
+ $ssf = round($pv * 0.13, 2);
|
|
|
10108
|
+ $con = $spread_data['contribute'] + round($pv * 0.13, 2);
|
|
|
10109
|
+ $score = $spread_data['score'] + round($pv * 0.13, 2);
|
|
|
10110
|
+ // $yj_amount = $spread_data['brokerage_price'] + round($pv * 0.13,2);
|
|
|
10111
|
+
|
|
|
10112
|
+ $yj_amount_90 = round($pv * 0.13, 2) * 0.9;
|
|
|
10113
|
+ $fgj_amount_10 = round($pv * 0.13, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10114
|
+
|
|
|
10115
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10116
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10117
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10118
|
+
|
|
|
10119
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10120
|
+ } else if ($spread_data['user_group'] == 6) {
|
|
|
10121
|
+ $ssf = round($pv * 0.15, 2);
|
|
|
10122
|
+ $con = $spread_data['contribute'] + round($pv * 0.15, 2);
|
|
|
10123
|
+ $score = $spread_data['score'] + round($pv * 0.15, 2);
|
|
|
10124
|
+
|
|
|
10125
|
+ $yj_amount_90 = round($pv * 0.15, 2) * 0.9;
|
|
|
10126
|
+ $fgj_amount_10 = round($pv * 0.15, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10127
|
+
|
|
|
10128
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10129
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10130
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10131
|
+
|
|
|
10132
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10133
|
+ } else if ($spread_data['user_group'] == 7) {
|
|
|
10134
|
+ $ssf = round($pv * 0.17, 2);
|
|
|
10135
|
+ $con = $spread_data['contribute'] + round($pv * 0.17, 2);
|
|
|
10136
|
+ $score = $spread_data['score'] + round($pv * 0.17, 2);
|
|
|
10137
|
+
|
|
|
10138
|
+
|
|
|
10139
|
+ $yj_amount_90 = round($pv * 0.17, 2) * 0.9;
|
|
|
10140
|
+ $fgj_amount_10 = round($pv * 0.17, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10141
|
+
|
|
|
10142
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10143
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10144
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10145
|
+
|
|
|
10146
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(['contribute'=> $con,'score'=> $score,'brokerage_price'=> $yj_amount,'annuity'=>$ylj_amount,'fugou'=>$fgj_amount]);
|
|
|
10147
|
+ }
|
|
|
10148
|
+
|
|
|
10149
|
+ //贡献值
|
|
|
10150
|
+ $this->con_log($spread_data['uid'], $pv, $store_order_data['order_id'], 12, "商贸区商品赠送贡献值");
|
|
|
10151
|
+ //积分
|
|
|
10152
|
+ $this->score_log($spread_data['uid'], $ssf, $store_order_data['order_id'], 12, "商贸区商品赠送积分");
|
|
|
10153
|
+ // //推广佣金
|
|
|
10154
|
+ $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
|
|
|
10155
|
+ //养老金
|
|
|
10156
|
+ $this->bill_user_log($spread_data['uid'], round($pv * 0.05, 2), $store_order_data['order_id'], 5, $group_order['group_order_sn'], '推广获得养老金' . round($pv * 0.05, 2), $store_order_data['mer_id'], 0);
|
|
|
10157
|
+ }
|
|
|
10158
|
+
|
|
|
10159
|
+ //普通用户推广人
|
|
|
10160
|
+ if ($spread_data['user_group'] == 1) {
|
|
|
10161
|
+ //给推广者分配佣金
|
|
|
10162
|
+
|
|
|
10163
|
+ $yj_amount_90 = round($pv * 0.21, 2) * 0.9;
|
|
|
10164
|
+ $fgj_amount_10 = round($pv * 0.21, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10165
|
+
|
|
|
10166
|
+ $yj_amount = $spread_data['brokerage_price'] + $yj_amount_90;
|
|
|
10167
|
+ $fgj_amount = $spread_data['fugou'] + $fgj_amount_10;
|
|
|
10168
|
+ $this->fugou_user_log($spread_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10169
|
+
|
|
|
10170
|
+ //Db::name('user')->where('uid',$spread_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
|
|
|
10171
|
+
|
|
|
10172
|
+ $con = $spread_data['contribute'] + round($pv * 0.21, 2);
|
|
|
10173
|
+ $score = $spread_data['score'] + round($pv * 0.21, 2);
|
|
|
10174
|
+
|
|
|
10175
|
+ //贡献值和积分
|
|
|
10176
|
+ // Db::name('user')->where('uid',$spread_data['uid'])->update(["contribute"=>$con,"score"=>$score]);
|
|
|
10177
|
+
|
|
|
10178
|
+ //推广养老金
|
|
|
10179
|
+ //推广佣金
|
|
|
10180
|
+ $this->bill_user_log($spread_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
|
|
|
10181
|
+ $this->con_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 12, "推广商贸区商品赠送贡献值");
|
|
|
10182
|
+ $this->score_log($spread_data['uid'], round($pv * 0.21, 2), $store_order_data['order_id'], 12, "推广商贸区商品赠送积分");
|
|
|
10183
|
+
|
|
|
10184
|
+
|
|
|
10185
|
+ }
|
|
|
10186
|
+
|
|
|
10187
|
+
|
|
|
10188
|
+ }
|
|
|
10189
|
+
|
|
|
10190
|
+ //锁客收益
|
|
|
10191
|
+ if ($user_data['mer_id'] != 0) {
|
|
|
10192
|
+
|
|
|
10193
|
+ $merchant_data = Db::name('merchant')->where('mer_id', $user_data['mer_id'])->find();
|
|
|
10194
|
+
|
|
|
10195
|
+ $merchant_user_data = Db::name('user')->where('uid', $merchant_data['uid'])->find();
|
|
|
10196
|
+
|
|
|
10197
|
+ if (!empty($merchant_user_data)) {
|
|
|
10198
|
+
|
|
|
10199
|
+ //给推广者分配佣金
|
|
|
10200
|
+
|
|
|
10201
|
+ $yj_amount_90 = round($pv * 0.05, 2) * 0.9;
|
|
|
10202
|
+ $fgj_amount_10 = round($pv * 0.05, 2) * 0.1;//推广者的佣金抽10%到个人复购金
|
|
|
10203
|
+
|
|
|
10204
|
+ $yj_amount = $merchant_user_data['brokerage_price'] + $yj_amount_90;
|
|
|
10205
|
+ $fgj_amount = $merchant_user_data['fugou'] + $fgj_amount_10;
|
|
|
10206
|
+ $this->fugou_user_log($merchant_data['uid'], $fgj_amount_10, $store_order_data['order_id'], 1);
|
|
|
10207
|
+
|
|
|
10208
|
+
|
|
|
10209
|
+ // Db::name('user')->where('uid',$merchant_data['uid'])->update(['brokerage_price'=>$yj_amount,'fugou'=>$fgj_amount]);
|
|
|
10210
|
+ //推广佣金
|
|
|
10211
|
+ $this->bill_user_log($merchant_data['uid'], $yj_amount_90, $store_order_data['order_id'], 3, $group_order['group_order_sn'], '推广获得拥金' . $yj_amount_90, $store_order_data['mer_id'], 0);
|
|
|
10212
|
+
|
|
|
10213
|
+ }
|
|
|
10214
|
+
|
|
|
10215
|
+ }
|
|
|
10216
|
+ }
|
|
10025
|
10217
|
}
|
|
10026
|
10218
|
|
|
10027
|
10219
|
//1.0老用户在新2.0表中升级
|