|
@@ -345,68 +345,69 @@ class Order extends BaseController
|
|
345
|
try {
|
345
|
try {
|
|
346
|
Db::startTrans();
|
346
|
Db::startTrans();
|
|
347
|
//查找是否有推荐人
|
347
|
//查找是否有推荐人
|
|
348
|
- $spreadUid = Db::name('user')->where('uid',$uid)->value('spread_uid');
|
|
|
|
349
|
- // 删除订单相关表 对应备份还没有创建
|
|
|
|
350
|
- $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
|
|
|
|
351
|
- $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
|
|
|
|
|
|
348
|
+ $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
|
|
352
|
//取出并删除 pv
|
349
|
//取出并删除 pv
|
|
353
|
- $pv = $this->getValue('user_pv_log', ['order_id' => $order_id, 'status' => 1,], 'pv');
|
|
|
|
354
|
- $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]); //status状态判断还没
|
|
|
|
|
|
350
|
+ $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
|
|
355
|
//取出 vr 消耗
|
351
|
//取出 vr 消耗
|
|
356
|
- $payVr = $this->getValue('user_sign_vr', ['order_id' => $order_id, 'type' => 2,], 'number');
|
|
|
|
357
|
- $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
|
|
|
|
|
|
352
|
+ $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
|
|
358
|
//取出购买赠送积分 / 支出积分
|
353
|
//取出购买赠送积分 / 支出积分
|
|
359
|
- $score = $this->getValue('user_sign_score', ['order_id' => $order_id, 'status' => 1,'source_type' => 3,'uid' => $uid,'pm' => 1], 'reward_socre');
|
|
|
|
360
|
- $payScore = $this->getValue('user_sign_score', ['order_id' => $order_id, 'status' => 1,'pm' => 2,'uid' => $uid,], 'reward_socre');
|
|
|
|
361
|
- // 取出推广赠送的积分和推广人的 uid
|
|
|
|
362
|
- $spreadScore = $this->getValue('user_sign_score', ['order_id', '=', $order_id, 'uid', '=', $spreadUid, 'status', '=', 1,], 'reward_socre');
|
|
|
|
363
|
- // 删除所有相关积分记录
|
|
|
|
364
|
- $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
|
|
|
|
|
|
354
|
+ $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
|
|
|
|
355
|
+ $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
|
|
365
|
// 贡献值
|
356
|
// 贡献值
|
|
366
|
- $gongXian = $this->getValue('user_sign_gongxian', ['order_id' => $order_id, 'status' => 1,'type' => 1,'uid' => $uid,], 'number');
|
|
|
|
367
|
- $spreadGongXian = 0;
|
|
|
|
368
|
- if ($spreadUid) {
|
|
|
|
369
|
- $spreadGongXian = $this->getValue('user_sign_gongxian', ['order_id' => $order_id, 'status' => 1,'type' => 1,'uid' => $spreadUid,], 'number');
|
|
|
|
370
|
- }
|
|
|
|
371
|
- $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
|
|
|
|
|
|
357
|
+ $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
|
|
372
|
// 养老金 / 推广养老金 / 推广佣金
|
358
|
// 养老金 / 推广养老金 / 推广佣金
|
|
373
|
- $yangLaoJin = $this->getValue('user_bill', ['link_id' => $order_id, 'status' => 1,'pm' => 1,'uid' => $uid,], 'number');
|
|
|
|
374
|
- $spreadYlj = 0;
|
|
|
|
375
|
- $spreadYongJin = 0;
|
|
|
|
376
|
- if ($spreadUid) {
|
|
|
|
377
|
- $spreadYlj = $this->getValue('user_bill', ['link_id' => $order_id, 'commission_type' => 5,'uid' => $spreadUid,], 'number'); //推荐获得养老金
|
|
|
|
378
|
- $spreadYongJin = $this->getValue('user_bill', ['link_id' => $order_id, 'commission_type' => 3,'uid' => $spreadUid,], 'number'); //推荐获得佣金
|
|
|
|
|
|
359
|
+ $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
|
|
|
|
360
|
+ if($spreadUid){
|
|
|
|
361
|
+ $spreadScore = 0;
|
|
|
|
362
|
+ $spreadGongXian = 0;
|
|
|
|
363
|
+ $spreadYlj = 0;
|
|
|
|
364
|
+ $spreadYongJin = 0;
|
|
|
|
365
|
+ $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
|
|
|
|
366
|
+ $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
|
|
|
|
367
|
+ $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
|
|
|
|
368
|
+ $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number'); //推荐获得佣金
|
|
|
|
369
|
+ $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
|
|
|
|
370
|
+ Db::name('backup_user')->insert($spreadUser);
|
|
|
|
371
|
+ Db::name('user')->where('uid', $spreadUid)->dec('score', $spreadScore)->update();
|
|
|
|
372
|
+ Db::name('user')->where('uid', $spreadUid)->dec('per_contribute', $spreadGongXian)->update();
|
|
|
|
373
|
+ Db::name('user')->where('uid', $spreadUid)->dec('annuity', $spreadYlj)->update();
|
|
|
|
374
|
+ Db::name('user')->where('uid', $spreadUid)->dec('brokerage_price', $spreadYongJin)->update();
|
|
379
|
}
|
375
|
}
|
|
380
|
- $spreadYongJinTwo = $this->getValue('user_bill', ['link_id' => $order_id, 'commission_type' => 3, ['uid', '<>', $spreadUid],],'number');
|
|
|
|
381
|
- $spreadYongJinTwoUid = $this->getValue('user_bill', ['link_id' => $order_id, 'commission_type' => 3, ['uid', '<>', $spreadUid],],'uid');
|
|
|
|
382
|
- $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
|
|
|
|
383
|
- $this->backupAndDelete('gz_logs', ['link_id' => $order_id]);
|
|
|
|
|
|
376
|
+ //扫吗消费
|
|
|
|
377
|
+ $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
|
|
|
|
378
|
+ $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
|
|
|
|
379
|
+ //第二推荐
|
|
|
|
380
|
+ $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '<>', $spreadUid],], 'number');
|
|
|
|
381
|
+ $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '<>', $spreadUid],], 'uid');
|
|
384
|
//更新对应的user表
|
382
|
//更新对应的user表
|
|
385
|
$user = Db::name('user')->where('uid', $uid)->find();
|
383
|
$user = Db::name('user')->where('uid', $uid)->find();
|
|
386
|
- if ($user) {
|
|
|
|
387
|
- Db::name('backup_user')->insert($user);
|
|
|
|
388
|
- }
|
|
|
|
|
|
384
|
+ Db::name('backup_user')->insert($user);
|
|
389
|
Db::name('user')->where('uid', $uid)->dec('pv', $pv)->update();
|
385
|
Db::name('user')->where('uid', $uid)->dec('pv', $pv)->update();
|
|
390
|
Db::name('user')->where('uid', $uid)->inc('vr', $payVr)->update();
|
386
|
Db::name('user')->where('uid', $uid)->inc('vr', $payVr)->update();
|
|
391
|
Db::name('user')->where('uid', $uid)->inc('score', $payScore)->update();
|
387
|
Db::name('user')->where('uid', $uid)->inc('score', $payScore)->update();
|
|
392
|
Db::name('user')->where('uid', $uid)->dec('score', $score)->update();
|
388
|
Db::name('user')->where('uid', $uid)->dec('score', $score)->update();
|
|
393
|
Db::name('user')->where('uid', $uid)->dec('contribute', $gongXian)->update();
|
389
|
Db::name('user')->where('uid', $uid)->dec('contribute', $gongXian)->update();
|
|
394
|
Db::name('user')->where('uid', $uid)->dec('annuity', $yangLaoJin)->update();
|
390
|
Db::name('user')->where('uid', $uid)->dec('annuity', $yangLaoJin)->update();
|
|
395
|
- //推荐人user表
|
|
|
|
396
|
- $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
|
|
|
|
397
|
- if ($spreadUser) {
|
|
|
|
398
|
- Db::name('backup_user')->insert($spreadUser);
|
|
|
|
399
|
- }
|
|
|
|
400
|
- Db::name('user')->where('uid', $spreadUid)->dec('score', $spreadScore)->update();
|
|
|
|
401
|
- Db::name('user')->where('uid', $spreadUid)->dec('per_contribute', $spreadGongXian)->update();
|
|
|
|
402
|
- Db::name('user')->where('uid', $spreadUid)->dec('annuity', $spreadYlj)->update();
|
|
|
|
403
|
- Db::name('user')->where('uid', $spreadUid)->dec('brokerage_price', $spreadYongJin)->update();
|
|
|
|
404
|
- //第二个推荐人
|
|
|
|
405
|
- $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
|
|
|
|
406
|
- if ($spreadUserTwo) {
|
|
|
|
|
|
391
|
+ //第二推荐
|
|
|
|
392
|
+ if($spreadYongJinTwoUid) {
|
|
|
|
393
|
+ $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
|
|
407
|
Db::name('backup_user')->insert($spreadUserTwo);
|
394
|
Db::name('backup_user')->insert($spreadUserTwo);
|
|
|
|
395
|
+ Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
|
|
|
|
396
|
+ }
|
|
|
|
397
|
+ if($smSpreadUid){
|
|
|
|
398
|
+ $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
|
|
|
|
399
|
+ Db::name('backup_user')->insert($smUserTwo);
|
|
|
|
400
|
+ Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
|
|
408
|
}
|
401
|
}
|
|
409
|
- Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
|
|
|
|
|
|
402
|
+ // 删除订单相关表
|
|
|
|
403
|
+ $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
|
|
|
|
404
|
+ $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
|
|
|
|
405
|
+ $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
|
|
|
|
406
|
+ $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
|
|
|
|
407
|
+ $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
|
|
|
|
408
|
+ $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
|
|
|
|
409
|
+ $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
|
|
|
|
410
|
+ $this->backupAndDelete('gz_logs', ['link_id' => $order_id]);
|
|
410
|
Db::commit();
|
411
|
Db::commit();
|
|
411
|
} catch (\Exception $e) {
|
412
|
} catch (\Exception $e) {
|
|
412
|
Db::rollback();
|
413
|
Db::rollback();
|
|
@@ -414,6 +415,7 @@ class Order extends BaseController
|
|
414
|
}
|
415
|
}
|
|
415
|
return app('json')->success('操作成功');
|
416
|
return app('json')->success('操作成功');
|
|
416
|
}
|
417
|
}
|
|
|
|
418
|
+
|
|
417
|
private function backupAndDelete($table, array $where)
|
419
|
private function backupAndDelete($table, array $where)
|
|
418
|
{
|
420
|
{
|
|
419
|
$backupTable = 'backup_' . $table;
|
421
|
$backupTable = 'backup_' . $table;
|