冻结和解冻礼品券逻辑修改和新增

This commit is contained in:
liu 2024-06-29 11:43:40 +08:00
parent cf0ac14419
commit cd952ac019
3 changed files with 101 additions and 6 deletions

View File

@ -444,7 +444,12 @@ class OrderLogic extends BaseLogic
if($order['uid'] && $order['pay_price'] >= 500){
$user_number = bcmul($order['pay_price'], '0.10', 2);
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id']])->update(['status'=>1]);
//todo 核销加冻结礼品券 解冻礼品券
self::addUserSing($order,2,$user_number);//冻结
self::addUserSing($order,4,$user_number,1,1);//解冻
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id'],'title'=>1])->update(['status'=>1]);
}
if ($order['spread_uid'] > 0) {
$spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find();
@ -464,6 +469,39 @@ class OrderLogic extends BaseLogic
}
}
/**
* 处理冻结和解冻 礼品券得记录
* @param $order // 订单
* @param $category // 分类
* @param $number // 金额
* @param int $pm //收支 0支出 1获得
* @type $type //类型 0冻结 1解冻
* @return true
*/
public static function addUserSing($order, $category, $number, int $pm=0, $type=0)
{
$user_sing = new UserSign();
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '购买商品获得兑换券',
// 'title' => PayNotifyLogic::getTitle($category,$number),
'title' => $category,
'financial_pm' => $pm,
'store_id' => $order['store_id'],
'number' => $number,
'type' => $type,
'status' => 1,
];
$user_sing->save($sing);
return true;
}
//不走二次分钱的核销
public static function lessWriteOff($params): bool
{

View File

@ -312,6 +312,7 @@ class UserLogic extends BaseLogic
$query->where('financial_pm',0);
}
$count = $query->count();
//todo 有就拿有得 没得就去获取对应得文本内容
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')

View File

@ -621,10 +621,27 @@ class PayNotifyLogic extends BaseLogic
{
$total_vip = bcmul($order['price'], 0.1, 2);
$user_sing = new UserSign();
$sing = [
//冻结
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '充值获得冻结兑换券',
// 'title' => '充值获得冻结兑换券',
// 'title' => self::getTitle(7,$total_vip),
'title' =>7,
'financial_pm' => 1,
'store_id' => $order['store_id'],
// 'type' => 1,
'status' => 1,
'number' => $total_vip,
'back_num' => $total_vip,
];
//礼品券得
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '充值获得冻结兑换券',
// 'title' => self::getTitle(4,$total_vip),
'title' => 4,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'type' => 1,
@ -632,7 +649,9 @@ class PayNotifyLogic extends BaseLogic
'number' => $total_vip,
'back_num' => $total_vip,
];
$user_sing->save($sing);
$user_sing->saveAll($sing);
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
return true;
@ -791,10 +810,13 @@ class PayNotifyLogic extends BaseLogic
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '购买商品获得兑换券',
// 'title' => '购买商品获得兑换券',
// 'title' => self::getTitle(1,$user_number),
'title' => 1,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'number' => $user_number,
'status' => 0,
];
$user_sing->save($sing);
}
@ -817,7 +839,9 @@ class PayNotifyLogic extends BaseLogic
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '购买商品获得兑换券',
// 'title' => '购买商品获得兑换券',
// 'title' => self::getTitle(1,$user_number),
'title' => 1,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'number' => $user_number,
@ -1055,4 +1079,36 @@ class PayNotifyLogic extends BaseLogic
(new StoreBranchProduct())->saveAll($updateData);
}
//礼品券相关对应文本
public static function getTitle($category, $amount)
{
switch ($category) {
/**冻结券**/
//收入
case 1:
return "购买商品{$amount}元获得冻结卷";
case 7:
return "充值{$amount}元获得冻结卷";
//支出
case 2:
return "核销商品{$amount}元解冻冻结卷";
case 3:
return "退款{$amount}元扣除冻结卷";
/**礼品券**/
//收入
case 4:
return "核销金额{$amount}元获得礼品卷";
//支出
case 5:
return "兑换{$amount}元商品扣除礼品卷";
case 6:
return "退款{$amount}元扣除礼品卷";
default:
return "订单支付{$amount}";
}
}
}