This commit is contained in:
liu 2024-07-02 17:31:33 +08:00
commit 0af9f3f65b
2 changed files with 39 additions and 106 deletions

View File

@ -427,14 +427,6 @@ class PayNotifyLogic extends BaseLogic
self::dealProductLog($order);
if ($order['shipping_type'] == 3) {
self::descStock($order['id']);
//直接加对应兑换券
if ($order->uid > 0) {
$level = User::where('id', $order->uid)->value('user_ship');
$discount = self::getDiscount($level);
$total_vip = bcmul($order['pay_price'], $discount, 2);
self::addNewUserSing($order, 8, $total_vip, 1, 1);
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
}
}
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
@ -469,14 +461,7 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']);
}
//退还 充值得兑换券
$level = User::where('id', $order->uid)->value('user_ship');
$discount = self::getDiscount($level);
$total_price = bcmul($orderRe->refund_price, $discount, 2);
self::addNewUserSing($orderRe, 3, $total_price); //冻结
self::addNewUserSing($orderRe, 6, $total_price, 0, 1); //解冻
self::descUserSing($orderRe);
// d($purchase_funds,$orderRe['refund_price'],$orderRe);
UserSignLogic::RefundRecharge($orderRe);
return true;
}
$order->status = OrderEnum::REFUND_PAY;
@ -490,7 +475,6 @@ class PayNotifyLogic extends BaseLogic
$user = User::where('id', $order['uid'])->findOrEmpty();
$capitalFlowDao = new CapitalFlowLogic($user);
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
$check_user_sing = UserSign::where('order_id', $order['order_id'])->count();
//对应比例得退礼品券逻辑
$discount = self::getDiscount($user->user_ship);
$total_price = bcmul($order->refund_price, $discount, 2);
@ -511,21 +495,12 @@ class PayNotifyLogic extends BaseLogic
//退款
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
}
UserSignLogic::RefundOrder($order);
if ($check_user_sing) {
//退还 兑换券
self::addNewUserSing($order, 3, $total_price); //冻结
self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻
self::descUserSing($order);
}
return true;
}
//积分
if ($check_user_sing) {
self::addNewUserSing($order, 3, $total_price); //冻结
self::addNewUserSing($order, 6, $total_price, 0, 1); //解冻
self::descUserSing($order);
}
UserSignLogic::RefundOrder($order);
//微信日志 user_order_refund
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
//处理财务流水退还
@ -534,76 +509,6 @@ class PayNotifyLogic extends BaseLogic
return true;
// self::afterPay($order,$extra['transaction_id']);
}
//冻结券和礼品券得操作
/**
* 处理冻结和解冻 礼品券得记录
* @param $order // 订单
* @param $category // 分类
* @param $number // 金额
* @param int $pm //收支 0支出 1获得
* @type $type //类型 0冻结 1解冻
* @return true
*/
public static function addNewUserSing($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 descUserSing($order)
{
// $user_sing = new UserSign();
if ($order['uid'] > 0) {
$level = User::where('id', $order['uid'])->value('user_ship');
$discount = self::getDiscount($level);
$user_number = bcmul($order['refund_price'], $discount, 2);
// $sing = [
// 'uid' => $order['uid'],
// 'order_id' => $order['order_id'],
// 'title' => '退款扣除兑换券',
// 'financial_pm' => 0,
// 'store_id' => $order['store_id'],
// 'number' => $user_number,
// ];
// $user_sing->save($sing);
// //删除之前获得的兑换券
// UserSign::where([
// 'order_id' => $order['order_id'],
// 'financial_pm' => 1,
// ])->update(['delete_time' => time()]);
$now_int = User::where('id', $order['uid'])->withTrashed()->find();
if ($now_int) {
if ($now_int['integral'] > $user_number) {
User::where('id', $order['uid'])->withTrashed()->dec('integral', $user_number)->update();
} else {
User::where('id', $order['uid'])->withTrashed()->dec('integral', $now_int['integral'])->update();
}
}
}
return true;
}
/**
* 现金退款相关

View File

@ -26,11 +26,25 @@ class UserSignLogic extends BaseLogic
//首充
$write = self::write($order, $total_vip, 0, 1, 9);
self::write_log($write, $total_vip, 0, 7);
self::write_log($write, $total_vip, 0, 9,0);
self::write_log($write, $total_vip, 0, 9, 0);
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
}
return true;
}
/**
* 充值退款
*/
public static function RefundRecharge($order)
{
$find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find();
if ($find) {
$find->status = -1;
$find->save();
$number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number');
self::write_log($find, $number, 0, 3, 0);
User::where('id', $order['uid'])->dec('integral', $number)->update();
}
}
/**
* 来自订单
@ -50,11 +64,25 @@ class UserSignLogic extends BaseLogic
if ($order['pay_price'] >= 500) {
$write = self::write($order, $total_vip, 1, 1, 4);
self::write_log($write, $total_vip, 1, 1);
self::write_log($write, $total_vip, 1, 2,0);
self::write_log($write, $total_vip, 1, 2, 0);
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
}
}
}
/**
* 订单退款
*/
public static function RefundOrder($order)
{
$find = UserSign::where('uid', $order['uid'])->where('order_id', $order['order_id'])->find();
if ($find) {
$find->status = -1;
$find->save();
$number = UserSignLog::where('sid', $find->id)->where('financial_pm', 0)->sum('number');
self::write_log($find, $number, 0, 3, 0);
User::where('id', $order['uid'])->dec('integral', $number)->update();
}
}
/**
* 核销
@ -66,20 +94,20 @@ class UserSignLogic extends BaseLogic
$find->status = 1;
$find->save();
User::where('id', $order->uid)->inc('integral', $find['number'])->update();
self::write_log($find, $find['number'], 1, 2,0);
self::write_log($find, $find['number'], 1, 2, 0);
// self::write_log($find, $find['number'], 1, 4);
}
}
/**
* 储存商品积分结算
*/
public static function storage($order_id,$price)
public static function storage($order_id, $price)
{
$find = UserSign::where(['order_id' => $order_id, 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find();
if ($find) {
self::write_log($find, $price, 1, 2,0);
self::write_log($find, $price, 1, 2,1);
if($price>$find['number']){
self::write_log($find, $price, 1, 2, 0);
self::write_log($find, $price, 1, 2, 1);
if ($price > $find['number']) {
$find->status = 1;
$find->save();
}
@ -143,7 +171,7 @@ class UserSignLogic extends BaseLogic
}
//礼品券相关对应文本
public static function getTitle($type, $amount,$number)
public static function getTitle($type, $amount, $number)
{
switch ($type) {
/**冻结券**/