修改:隐藏商户积分&平台积分相关操作

This commit is contained in:
wuhui_zzw 2024-01-10 16:42:45 +08:00
parent 946f0f55ec
commit 8e8f25ebc8
5 changed files with 1351 additions and 57 deletions

View File

@ -147,8 +147,8 @@ class PointsOrderCreateRepository
$cart['cost'] = $total_cost;
}
// 判断:当前商户积分是否充足
$holdMerIntegral = app()->make(IntegralRepository::class)->getMerIntegral((int)$user->uid,(int)$merchantCart['mer_id']);// 用户持有的该商户积分总数
if($holdMerIntegral < $total_integral) throw new ValidateException("积分不足,剩余{$holdMerIntegral}商户积分");
// $holdMerIntegral = app()->make(IntegralRepository::class)->getMerIntegral((int)$user->uid,(int)$merchantCart['mer_id']);// 用户持有的该商户积分总数
// if($holdMerIntegral < $total_integral) throw new ValidateException("积分不足,剩余{$holdMerIntegral}商户积分");
unset($cart);
if (count($merchantCartList) > 1 || count($merchantCart['list']) > 1) {
@ -335,12 +335,12 @@ class PointsOrderCreateRepository
$groupOrder = $storeGroupOrderRepository->create($groupOrder);
// 减少积分
if ($groupOrder['integral'] > 0) {
foreach ($_orderList as $k => $order) {
/* foreach ($_orderList as $k => $order) {
foreach ($order['cartInfo']['list'] as $cart) {
// 减少对应的商户积分
app()->make(IntegralRepository::class)->changeIntegral((int)$user['uid'],(int)$cart->mer_id,(float)sprintf("%.2f",0 - (int)$cart->integral));
}
}
}*/
// 减少总持有积分
$user->integral = bcsub($user->integral, $groupOrder['integral'], 0);
$userBillRepository->decBill($user['uid'],'integral','points_order',[
@ -348,7 +348,7 @@ class PointsOrderCreateRepository
'status' => 1,
'title' => '积分商城兑换商品',
'number' => $groupOrder['integral'],
'mark' => '积分商城兑换商品使用商户积分'.floatval($groupOrder['integral']),
'mark' => '积分商城兑换商品使用积分'.floatval($groupOrder['integral']),
'balance' => $user->integral
]);
$user->save();

View File

@ -640,34 +640,34 @@ class StoreOrderRepository extends BaseRepository
public function giveIntegral($groupOrder){
// Log::info('赠送积分 - group-order' . var_export(is_array($groupOrder->user->toArray()) ? $groupOrder->user->toArray() : $groupOrder->user, true));
// 修改每个订单单独赠送积分并且实时到账同时区分商户id
foreach($groupOrder->orderList as $orderInfo){
$giveIntegral = (float)sprintf("%.2f",$orderInfo->give_integral);
if ($giveIntegral > 0) {
// 总积分到账 & 记录总平台积分变更日志
app()->make(UserRepository::class)->incIntegral((int)$orderInfo->uid,$giveIntegral,'订单赠送积分','lock',[
'link_id' => $orderInfo->order_id,
'number' => $giveIntegral,
'mark' => '成功消费' . (float)sprintf("%.2f",$orderInfo->pay_price) . '元,赠送商户积分' . $giveIntegral
]);
// 商户积分变更
app()->make(IntegralRepository::class)->changeIntegral((int)$orderInfo->uid,(int)$orderInfo->mer_id,$giveIntegral);
// 记录商户端积分变更日志
$user = app()->make(UserRepository::class)->get($orderInfo->uid);
app()->make(UserBillRepository::class)->insertAll([[
'uid' => $orderInfo->uid,
'link_id' => $orderInfo->order_id,
'pm' => 0,
'title' => '订单赠送积分',
'category' => 'mer_integral',
'type' => 'lock',
'number' => $giveIntegral,
'balance' => $user->integral,
'mark' => '成功消费' . (float)sprintf("%.2f",$orderInfo->pay_price) . '元,赠送商户积分' . $giveIntegral,
'mer_id' => $orderInfo->mer_id,
'status' => 1
]]);
}
}
// foreach($groupOrder->orderList as $orderInfo){
// $giveIntegral = (float)sprintf("%.2f",$orderInfo->give_integral);
// if ($giveIntegral > 0) {
// // 总积分到账 & 记录总平台积分变更日志
// app()->make(UserRepository::class)->incIntegral((int)$orderInfo->uid,$giveIntegral,'订单赠送积分','lock',[
// 'link_id' => $orderInfo->order_id,
// 'number' => $giveIntegral,
// 'mark' => '成功消费' . (float)sprintf("%.2f",$orderInfo->pay_price) . '元,赠送商户积分' . $giveIntegral
// ]);
// // 商户积分变更
// app()->make(IntegralRepository::class)->changeIntegral((int)$orderInfo->uid,(int)$orderInfo->mer_id,$giveIntegral);
// // 记录商户端积分变更日志
// $user = app()->make(UserRepository::class)->get($orderInfo->uid);
// app()->make(UserBillRepository::class)->insertAll([[
// 'uid' => $orderInfo->uid,
// 'link_id' => $orderInfo->order_id,
// 'pm' => 0,
// 'title' => '订单赠送积分',
// 'category' => 'mer_integral',
// 'type' => 'lock',
// 'number' => $giveIntegral,
// 'balance' => $user->integral,
// 'mark' => '成功消费' . (float)sprintf("%.2f",$orderInfo->pay_price) . '元,赠送商户积分' . $giveIntegral,
// 'mer_id' => $orderInfo->mer_id,
// 'status' => 1
// ]]);
// }
// }
# 2023-11-7 弃用,由指定时间到账修改为实时到账,并且区分每个商户的积分
// if ($groupOrder->give_integral > 0) {

View File

@ -1182,7 +1182,7 @@ class StoreRefundOrderRepository extends BaseRepository
{
if ($refundOrder->refund_price > 0 && $refundOrder->order->pay_price > 0) {
$userBillRepository = app()->make(UserBillRepository::class);
$bill = $userBillRepository->getWhere(['category' => 'integral', 'type' => 'lock', 'link_id' => $refundOrder->order_id]);// 获取积分赠送记录
/*$bill = $userBillRepository->getWhere(['category' => 'integral', 'type' => 'lock', 'link_id' => $refundOrder->order_id]);// 获取积分赠送记录
if ($bill) {
// 计算扣除的积分
if ($refundOrder->order->status == -1) $number = bcsub($bill->number, $userBillRepository->refundIntegral($refundOrder->order_id, $bill->uid), 0);
@ -1203,9 +1203,9 @@ class StoreRefundOrderRepository extends BaseRepository
]);
// 赠送的都是商户积分 这里也要退商户积分
app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',0 - $number));
}
}*/
/*$bill = $userBillRepository->getWhere(['category' => 'integral', 'type' => 'lock', 'link_id' => $refundOrder->order->group_order_id]);
$bill = $userBillRepository->getWhere(['category' => 'integral', 'type' => 'lock', 'link_id' => $refundOrder->order->group_order_id]);
if ($bill && $bill->status != 1) {
if ($refundOrder->order->status == -1) {
@ -1224,7 +1224,7 @@ class StoreRefundOrderRepository extends BaseRepository
'mark' => '订单退款扣除赠送积分' . intval($number),
'balance' => $refundOrder->user->integral
]);
}*/
}
}
}
@ -1352,17 +1352,17 @@ class StoreRefundOrderRepository extends BaseRepository
$userIntegral = $make->get($refundOrder->uid)->integral;
$make1 = app()->make(UserBillRepository::class);
// 判断:根据订单抵扣使用积分 退还平台积分或者商户积分
if((float)$refundOrder->order->use_mer_integral > 0){
// 使用的商户积分
app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral));
$mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分';
}else{
// 使用的平台积分
app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral));
$mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分';
}
// if((float)$refundOrder->order->use_mer_integral > 0){
// // 使用的商户积分
// app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral));
// $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分';
// }else{
// // 使用的平台积分
// app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral));
// $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分';
// }
$mark = '订单退款,返还' . intval($refundOrder->integral) . '积分';
$make1->incBill($refundOrder->uid, 'integral', 'refund', [
'link_id' => $refundOrder->order_id,
'status' => 1,

View File

@ -50,13 +50,15 @@ class StoreOrder extends BaseController
$addressId = (int)$this->request->param('address_id');
$couponIds = (array)$this->request->param('use_coupon', []);
$takes = (array)$this->request->param('takes', []);
$usePlatformIntegral = (bool)$this->request->param('use_platform_integral', false);
$useMerIntegral = (bool)$this->request->param('use_mer_integral', false);
// $usePlatformIntegral = (bool)$this->request->param('use_platform_integral', false);
// $useMerIntegral = (bool)$this->request->param('use_mer_integral', false);
$useIntegral = (bool)$this->request->param('use_integral', false);
$user = $this->request->userInfo();
$uid = $user->uid;
if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
return app('json')->fail('数据无效');
$orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $usePlatformIntegral,$useMerIntegral, $addressId);
// $orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $usePlatformIntegral,$useMerIntegral, $addressId);
$orderInfo = $orderCreateRepository->v2CartIdByOrderInfo($user, $cartId, $takes, $couponIds, $useIntegral, $addressId);
return app('json')->success($orderInfo);
}
@ -99,8 +101,12 @@ class StoreOrder extends BaseController
// if (!$addressId)
// return app('json')->fail('请选择地址');
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $addressId, $post) {
return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $addressId, $post);
// $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $addressId, $post) {
// return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $addressId, $post);
// });
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) {
return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
});
if ($groupOrder['pay_price'] == 0) {