|
@@ -152,6 +152,21 @@ class Pay extends Api |
|
@@ -152,6 +152,21 @@ class Pay extends Api |
152
|
}
|
152
|
}
|
153
|
$PayTime = $PayOrderInfo['pay_time'] * 1000;
|
153
|
$PayTime = $PayOrderInfo['pay_time'] * 1000;
|
154
|
$GuanYiCloud->addOrder($PayOrderInfo['OrderSn'], date('Y-m-d H:i:s', $OrderInfo['createtime']), $PayTime, $UnionID, $OrderInfo['name'], $OrderInfo['mobile'], $OrderInfo['address'] . '/' . $OrderInfo['address_con'], $City[0], $City[1], $City[2], $details, $PayOrderInfo['money'], $PayOrderInfo['PayOrder']);
|
154
|
$GuanYiCloud->addOrder($PayOrderInfo['OrderSn'], date('Y-m-d H:i:s', $OrderInfo['createtime']), $PayTime, $UnionID, $OrderInfo['name'], $OrderInfo['mobile'], $OrderInfo['address'] . '/' . $OrderInfo['address_con'], $City[0], $City[1], $City[2], $details, $PayOrderInfo['money'], $PayOrderInfo['PayOrder']);
|
|
|
155
|
+ /*补充逻辑*/
|
|
|
156
|
+ $WaterUserNum = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
|
|
|
157
|
+ //更改用户积分
|
|
|
158
|
+ Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $WaterUserNum['num'] + floor($OrderInfo['total'])]);
|
|
|
159
|
+ //添加用户积分记录
|
|
|
160
|
+ $WaterUserNumPay = [
|
|
|
161
|
+ 'user_id' => $PayOrderInfo['user_id'],
|
|
|
162
|
+ 'status' => 1,
|
|
|
163
|
+ 'type' => 10,
|
|
|
164
|
+ 'num' => floor($OrderInfo['total']),
|
|
|
165
|
+ 'up_num' => $WaterUserNum['num'] + floor($OrderInfo['total']),
|
|
|
166
|
+ 'createtime' => time()
|
|
|
167
|
+ ];
|
|
|
168
|
+ Db::name('num')->insert($WaterUserNumPay);
|
|
|
169
|
+ /*补充逻辑*/
|
155
|
//是否首次下单
|
170
|
//是否首次下单
|
156
|
$FirstPay = Db::name('order')->where('OrderSn', 'NEQ', $PayOrderInfo['OrderSn'])->where('status', 'IN', '1,2,3,4,5')->find();
|
171
|
$FirstPay = Db::name('order')->where('OrderSn', 'NEQ', $PayOrderInfo['OrderSn'])->where('status', 'IN', '1,2,3,4,5')->find();
|
157
|
if (empty($FirstPay)) {
|
172
|
if (empty($FirstPay)) {
|
|
@@ -163,7 +178,7 @@ class Pay extends Api |
|
@@ -163,7 +178,7 @@ class Pay extends Api |
163
|
//查询用户积分
|
178
|
//查询用户积分
|
164
|
$FirstPayUserinfo = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
|
179
|
$FirstPayUserinfo = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
|
165
|
//更改用户积分
|
180
|
//更改用户积分
|
166
|
- $UpdateFirstPay = Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $FirstPayUserinfo['num'] + ($OrderInfo['total'] * 2)]);
|
181
|
+ $UpdateFirstPay = Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $FirstPayUserinfo['num'] + (floor($OrderInfo['total']) * 2)]);
|
167
|
if (!$UpdateFirstPay) {
|
182
|
if (!$UpdateFirstPay) {
|
168
|
$this->error('更改用户积分失败失败', 0);
|
183
|
$this->error('更改用户积分失败失败', 0);
|
169
|
die;
|
184
|
die;
|
|
@@ -173,8 +188,8 @@ class Pay extends Api |
|
@@ -173,8 +188,8 @@ class Pay extends Api |
173
|
'user_id' => $PayOrderInfo['user_id'],
|
188
|
'user_id' => $PayOrderInfo['user_id'],
|
174
|
'status' => 1,
|
189
|
'status' => 1,
|
175
|
'type' => 5,
|
190
|
'type' => 5,
|
176
|
- 'num' => $OrderInfo['total'] * 2,
|
|
|
177
|
- 'up_num' => $FirstPayUserinfo['num'] + ($OrderInfo['total'] * 2),
|
191
|
+ 'num' => floor($OrderInfo['total']) * 2,
|
|
|
192
|
+ 'up_num' => $FirstPayUserinfo['num'] + (floor($OrderInfo['total']) * 2),
|
178
|
'createtime' => time()
|
193
|
'createtime' => time()
|
179
|
];
|
194
|
];
|
180
|
Db::name('num')->insert($InserNumSql);
|
195
|
Db::name('num')->insert($InserNumSql);
|
|
@@ -252,42 +267,42 @@ class Pay extends Api |
|
@@ -252,42 +267,42 @@ class Pay extends Api |
252
|
}
|
267
|
}
|
253
|
}
|
268
|
}
|
254
|
//自购返现
|
269
|
//自购返现
|
255
|
- $ZiGou = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
|
|
|
256
|
- if ($ZiGou['level'] != 1) {
|
|
|
257
|
- //不是普通会员 产生自购返现
|
|
|
258
|
- //自购折扣
|
|
|
259
|
- $buycount = Db::name('level')->where('type', $ZiGou['level'])->value('buycount');
|
|
|
260
|
- $ZigouMoney = (1 - $buycount) * $OrderInfo['total'];
|
|
|
261
|
- //扣除积分
|
|
|
262
|
- Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(
|
|
|
263
|
- [
|
|
|
264
|
- 'num' => $ZiGou['num'] - $ZigouMoney,
|
|
|
265
|
- 'money' => $ZiGou['money'] + $ZigouMoney
|
|
|
266
|
- ]
|
|
|
267
|
- );
|
|
|
268
|
- //积分表添加记录
|
|
|
269
|
- //添加用户积分记录
|
|
|
270
|
- $ZiGouSql = [
|
|
|
271
|
- 'user_id' => $PayOrderInfo['user_id'],
|
|
|
272
|
- 'status' => 0,
|
|
|
273
|
- 'type' => 4,
|
|
|
274
|
- 'num' => $ZigouMoney,
|
|
|
275
|
- 'up_num' => $ZiGou['num'] - $ZigouMoney,
|
|
|
276
|
- 'createtime' => time()
|
|
|
277
|
- ];
|
|
|
278
|
- Db::name('num')->insert($ZiGouSql);
|
|
|
279
|
- //添加收益记录
|
|
|
280
|
- $ZiGouSqlMoney = [
|
|
|
281
|
- 'user_id' => $PayOrderInfo['user_id'],
|
|
|
282
|
- 'money' => $ZigouMoney,
|
|
|
283
|
- 'touser_id' => $PayOrderInfo['user_id'],
|
|
|
284
|
- 'status' => 0,
|
|
|
285
|
- 'type' => 1,
|
|
|
286
|
- 'createtime' => time(),
|
|
|
287
|
- 'OrderSn' => $PayOrderInfo['OrderSn']
|
|
|
288
|
- ];
|
|
|
289
|
- Db::name('money')->insert($ZiGouSqlMoney);
|
|
|
290
|
- }
|
270
|
+// $ZiGou = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
|
|
|
271
|
+// if ($ZiGou['level'] != 1) {
|
|
|
272
|
+// //不是普通会员 产生自购返现
|
|
|
273
|
+// //自购折扣
|
|
|
274
|
+// $buycount = Db::name('level')->where('type', $ZiGou['level'])->value('buycount');
|
|
|
275
|
+// $ZigouMoney = (1 - $buycount) * $OrderInfo['total'];
|
|
|
276
|
+// //扣除积分
|
|
|
277
|
+// Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(
|
|
|
278
|
+// [
|
|
|
279
|
+// 'num' => $ZiGou['num'] - $ZigouMoney,
|
|
|
280
|
+// 'money' => $ZiGou['money'] + $ZigouMoney
|
|
|
281
|
+// ]
|
|
|
282
|
+// );
|
|
|
283
|
+// //积分表添加记录
|
|
|
284
|
+// //添加用户积分记录
|
|
|
285
|
+// $ZiGouSql = [
|
|
|
286
|
+// 'user_id' => $PayOrderInfo['user_id'],
|
|
|
287
|
+// 'status' => 0,
|
|
|
288
|
+// 'type' => 4,
|
|
|
289
|
+// 'num' => $ZigouMoney,
|
|
|
290
|
+// 'up_num' => $ZiGou['num'] - $ZigouMoney,
|
|
|
291
|
+// 'createtime' => time()
|
|
|
292
|
+// ];
|
|
|
293
|
+// Db::name('num')->insert($ZiGouSql);
|
|
|
294
|
+// //添加收益记录
|
|
|
295
|
+// $ZiGouSqlMoney = [
|
|
|
296
|
+// 'user_id' => $PayOrderInfo['user_id'],
|
|
|
297
|
+// 'money' => $ZigouMoney,
|
|
|
298
|
+// 'touser_id' => $PayOrderInfo['user_id'],
|
|
|
299
|
+// 'status' => 0,
|
|
|
300
|
+// 'type' => 1,
|
|
|
301
|
+// 'createtime' => time(),
|
|
|
302
|
+// 'OrderSn' => $PayOrderInfo['OrderSn']
|
|
|
303
|
+// ];
|
|
|
304
|
+// Db::name('money')->insert($ZiGouSqlMoney);
|
|
|
305
|
+// }
|
291
|
//二级分佣
|
306
|
//二级分佣
|
292
|
//查询用户上级和上级的上级
|
307
|
//查询用户上级和上级的上级
|
293
|
$FatherUserId = Db::name('group')->where('user_id', $PayOrderInfo['user_id'])->value('fuser_id');
|
308
|
$FatherUserId = Db::name('group')->where('user_id', $PayOrderInfo['user_id'])->value('fuser_id');
|