修改加入冻结兑换券中
This commit is contained in:
parent
9ded85b66f
commit
bc6855fc7c
@ -206,6 +206,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
OrderLogic::writeOff($params);
|
||||
}
|
||||
self::dealProductLog($order);
|
||||
self::addFlowLog($order);
|
||||
// if($order['shipping_type'] == 3){
|
||||
// self::descStock($order['id']);
|
||||
// }
|
||||
@ -220,9 +221,9 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
//查询当前用户有无对应的充值的冻结金额
|
||||
if($order['uid'] >0 ){
|
||||
$query = VipFlow::where([
|
||||
$query = UserSign::where([
|
||||
'user_id'=>$order['uid'],
|
||||
'type'=>2,
|
||||
'type'=>1,
|
||||
'status'=>0
|
||||
]);
|
||||
$query1 = clone $query;
|
||||
@ -234,30 +235,27 @@ class PayNotifyLogic extends BaseLogic
|
||||
if($count == 1){
|
||||
//存在拆单子否
|
||||
//少了就冻结减去这个对应的金额
|
||||
$one = VipFlow::where([
|
||||
$one = UserSign::where([
|
||||
'user_id'=>$order['uid'],
|
||||
'type'=>2,
|
||||
'type'=>1,
|
||||
'status'=>0
|
||||
])->find();
|
||||
$data = [
|
||||
'vip_flow_id'=>$one['id'],
|
||||
'order_id' => $order['id'],
|
||||
'order_sn' => $order['order_id'],
|
||||
'user_id' => $order['uid'],
|
||||
'pay_type' => $pay_type ?? 1,
|
||||
'status' => 1,
|
||||
'type' => 1,
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '充值获得冻结兑换券',
|
||||
'financial_pm' => 1,
|
||||
'store_id' => $order['store_id'],
|
||||
'staff_id' => $order['staff_id'],
|
||||
'create_time' => time()
|
||||
'type' => 1,
|
||||
];
|
||||
|
||||
if($one['back_num'] >= $backPurchase){
|
||||
$data['number'] =$backPurchase;
|
||||
Db::name('la_vip_flow_log')->insert($data);
|
||||
Db::name('user_sign_log')->insert($data);
|
||||
//总的减去采购款百分之十剩余的
|
||||
$wait = bcsub($one['back_num'],$backPurchase,2);
|
||||
if(empty($wait)){
|
||||
VipFlow::where('id',$one['id'])->update(
|
||||
UserSign::where('id',$one['id'])->update(
|
||||
[
|
||||
'back_num'=>0,
|
||||
'status'=>1
|
||||
@ -265,7 +263,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
);
|
||||
}else{
|
||||
//add
|
||||
VipFlow::where('id',$one['id'])->update([
|
||||
UserSign::where('id',$one['id'])->update([
|
||||
[
|
||||
'back_num'=>$wait
|
||||
]
|
||||
@ -273,12 +271,13 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
//并且加到对应的用户的采购款中
|
||||
User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update();
|
||||
}else{
|
||||
}
|
||||
else{
|
||||
//对比采购款支付的多少 多了就拿冻结金额即可
|
||||
$data['number'] =$one['number'];
|
||||
//都存到对应的log日志
|
||||
Db::name('la_vip_flow_log')->insert($data);
|
||||
VipFlow::where('id',$one['id'])->update(
|
||||
Db::name('user_sign_log')->insert($data);
|
||||
UserSign::where('id',$one['id'])->update(
|
||||
[
|
||||
'back_num'=>0,
|
||||
'status'=>1
|
||||
@ -292,56 +291,46 @@ class PayNotifyLogic extends BaseLogic
|
||||
//大于0的时候
|
||||
//先处理金额大的再处理剩余的
|
||||
/**** 把所有的金额改为正的再加一条后再加***/
|
||||
VipFlow::where([
|
||||
UserSign::where([
|
||||
'user_id'=>$order['uid'],
|
||||
'type'=>2,
|
||||
'type'=>1,
|
||||
'status'=>0
|
||||
])->update([
|
||||
'status'=>1,
|
||||
'remark'=>json_encode($ids)
|
||||
'title'=>json_encode($ids)
|
||||
]);
|
||||
if ($check >= $backPurchase) {
|
||||
//补一条待解冻的
|
||||
// $data = [
|
||||
// 'order_id' => $order['id'],
|
||||
// 'transaction_id' => $transaction_id ?? 0,
|
||||
// 'order_sn' => $order['order_id'],
|
||||
// 'user_id' => $order['uid'],
|
||||
// 'number' => $total_vip,
|
||||
// 'back_num' => $total_vip,
|
||||
// 'pay_type' => $pay_type ?? 1,
|
||||
// 'status' => 0,
|
||||
// 'type' => 1,
|
||||
// 'store_id' => $order['store_id'],
|
||||
// 'staff_id' => $order['staff_id'],
|
||||
// 'create_time' => time()
|
||||
// ];
|
||||
// Db::name('vip_flow')->insert($data);
|
||||
$left = bcsub($check,$backPurchase,2);
|
||||
if($left > 0){
|
||||
$data = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '补冻结兑换券',
|
||||
'financial_pm' => 0,
|
||||
'store_id' => $order['store_id'],
|
||||
'type' => 1,
|
||||
];
|
||||
$data['number'] =$check;
|
||||
Db::name('user_sign')->insert($data);
|
||||
}
|
||||
User::where('id',$order['uid'])->inc('purchase_funds',$backPurchase)->update();//add
|
||||
|
||||
}else{
|
||||
//log
|
||||
$data = [
|
||||
'vip_flow_id'=>0,
|
||||
'remark'=>$ids,
|
||||
'order_id' => $order['id'],
|
||||
'order_sn' => $order['order_id'],
|
||||
'user_id' => $order['uid'],
|
||||
'pay_type' => $pay_type ?? 1,
|
||||
'status' => 1,
|
||||
'type' => 1,
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '充值获得冻结兑换券',
|
||||
'financial_pm' => 1,
|
||||
'store_id' => $order['store_id'],
|
||||
'staff_id' => $order['staff_id'],
|
||||
'create_time' => time()
|
||||
'type' => 1,
|
||||
];
|
||||
$data['number'] =$check;
|
||||
Db::name('la_vip_flow_log')->insert($data);
|
||||
Db::name('user_sign_log')->insert($data);
|
||||
User::where('id',$order['uid'])->inc('purchase_funds',$check)->update();//add
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -349,7 +338,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -594,21 +583,19 @@ class PayNotifyLogic extends BaseLogic
|
||||
public static function dealRechargeFrozen($order)
|
||||
{
|
||||
$total_vip = bcmul($order['price'],0.1,2);
|
||||
$data = [
|
||||
'order_id' => $order['id'],
|
||||
'transaction_id' => $transaction_id ?? 0,
|
||||
'order_sn' => $order['order_id'],
|
||||
'user_id' => $order['uid'],
|
||||
$user_sing = new UserSign();
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '充值获得冻结兑换券',
|
||||
'financial_pm' => 1,
|
||||
'store_id' => $order['store_id'],
|
||||
'type' => 1,
|
||||
'number' => $total_vip,
|
||||
'back_num' => $total_vip,
|
||||
'pay_type' => $pay_type ?? 1,
|
||||
'status' => 0,
|
||||
'type' => 1,
|
||||
'store_id' => $order['store_id'],
|
||||
'staff_id' => $order['staff_id'],
|
||||
'create_time' => time()
|
||||
];
|
||||
Db::name('vip_flow')->insert($data);
|
||||
$user_sing->save($sing);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user