作者 王智

xiugai

... ... @@ -241,6 +241,9 @@ class Order extends Api
]
);
}
//减少积分
$UserNum = Db::name('user')->where('id', $UserId)->find();
Db::name('user')->where('id', $UserId)->update(['num' => $UserNum['num'] - floor($OrderInfo['total'])]);
}
//更改上级活动钱包减少待入账 增加待提现
$FuserId = Db::name('group')->where('user_id', $UserId)->value('fuser_id');
... ...
... ... @@ -152,6 +152,21 @@ class Pay extends Api
}
$PayTime = $PayOrderInfo['pay_time'] * 1000;
$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']);
/*补充逻辑*/
$WaterUserNum = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
//更改用户积分
Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $WaterUserNum['num'] + floor($OrderInfo['total'])]);
//添加用户积分记录
$WaterUserNumPay = [
'user_id' => $PayOrderInfo['user_id'],
'status' => 1,
'type' => 10,
'num' => floor($OrderInfo['total']),
'up_num' => $WaterUserNum['num'] + floor($OrderInfo['total']),
'createtime' => time()
];
Db::name('num')->insert($WaterUserNumPay);
/*补充逻辑*/
//是否首次下单
$FirstPay = Db::name('order')->where('OrderSn', 'NEQ', $PayOrderInfo['OrderSn'])->where('status', 'IN', '1,2,3,4,5')->find();
if (empty($FirstPay)) {
... ... @@ -163,7 +178,7 @@ class Pay extends Api
//查询用户积分
$FirstPayUserinfo = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
//更改用户积分
$UpdateFirstPay = Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $FirstPayUserinfo['num'] + ($OrderInfo['total'] * 2)]);
$UpdateFirstPay = Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(['num' => $FirstPayUserinfo['num'] + (floor($OrderInfo['total']) * 2)]);
if (!$UpdateFirstPay) {
$this->error('更改用户积分失败失败', 0);
die;
... ... @@ -173,8 +188,8 @@ class Pay extends Api
'user_id' => $PayOrderInfo['user_id'],
'status' => 1,
'type' => 5,
'num' => $OrderInfo['total'] * 2,
'up_num' => $FirstPayUserinfo['num'] + ($OrderInfo['total'] * 2),
'num' => floor($OrderInfo['total']) * 2,
'up_num' => $FirstPayUserinfo['num'] + (floor($OrderInfo['total']) * 2),
'createtime' => time()
];
Db::name('num')->insert($InserNumSql);
... ... @@ -252,42 +267,42 @@ class Pay extends Api
}
}
//自购返现
$ZiGou = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
if ($ZiGou['level'] != 1) {
//不是普通会员 产生自购返现
//自购折扣
$buycount = Db::name('level')->where('type', $ZiGou['level'])->value('buycount');
$ZigouMoney = (1 - $buycount) * $OrderInfo['total'];
//扣除积分
Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(
[
'num' => $ZiGou['num'] - $ZigouMoney,
'money' => $ZiGou['money'] + $ZigouMoney
]
);
//积分表添加记录
//添加用户积分记录
$ZiGouSql = [
'user_id' => $PayOrderInfo['user_id'],
'status' => 0,
'type' => 4,
'num' => $ZigouMoney,
'up_num' => $ZiGou['num'] - $ZigouMoney,
'createtime' => time()
];
Db::name('num')->insert($ZiGouSql);
//添加收益记录
$ZiGouSqlMoney = [
'user_id' => $PayOrderInfo['user_id'],
'money' => $ZigouMoney,
'touser_id' => $PayOrderInfo['user_id'],
'status' => 0,
'type' => 1,
'createtime' => time(),
'OrderSn' => $PayOrderInfo['OrderSn']
];
Db::name('money')->insert($ZiGouSqlMoney);
}
// $ZiGou = Db::name('user')->where('id', $PayOrderInfo['user_id'])->find();
// if ($ZiGou['level'] != 1) {
// //不是普通会员 产生自购返现
// //自购折扣
// $buycount = Db::name('level')->where('type', $ZiGou['level'])->value('buycount');
// $ZigouMoney = (1 - $buycount) * $OrderInfo['total'];
// //扣除积分
// Db::name('user')->where('id', $PayOrderInfo['user_id'])->update(
// [
// 'num' => $ZiGou['num'] - $ZigouMoney,
// 'money' => $ZiGou['money'] + $ZigouMoney
// ]
// );
// //积分表添加记录
// //添加用户积分记录
// $ZiGouSql = [
// 'user_id' => $PayOrderInfo['user_id'],
// 'status' => 0,
// 'type' => 4,
// 'num' => $ZigouMoney,
// 'up_num' => $ZiGou['num'] - $ZigouMoney,
// 'createtime' => time()
// ];
// Db::name('num')->insert($ZiGouSql);
// //添加收益记录
// $ZiGouSqlMoney = [
// 'user_id' => $PayOrderInfo['user_id'],
// 'money' => $ZigouMoney,
// 'touser_id' => $PayOrderInfo['user_id'],
// 'status' => 0,
// 'type' => 1,
// 'createtime' => time(),
// 'OrderSn' => $PayOrderInfo['OrderSn']
// ];
// Db::name('money')->insert($ZiGouSqlMoney);
// }
//二级分佣
//查询用户上级和上级的上级
$FatherUserId = Db::name('group')->where('user_id', $PayOrderInfo['user_id'])->value('fuser_id');
... ...
... ... @@ -170,7 +170,7 @@ class Update extends Api
"title": "好友邀请优惠券",
"door": 100, //门槛金额
"del_price": "30.00", //优惠金额
"exp_time": "2021-03-24 13:35:22"
"exp_time": "2021-02-22 13:35:22—2021-03-24 13:35:22"//有效期
}
]
}
... ...