修复:查询条件错误导致餐费积分未正常过期和解冻

增加:在线买单 - 增加餐费积分抵扣功能
This commit is contained in:
wuhui_zzw 2024-06-21 15:34:45 +08:00
parent 7e1081cba4
commit 2c191a448d
6 changed files with 26 additions and 10 deletions

View File

@ -51,7 +51,7 @@ class StoreGroupOrderDao extends BaseDao
->when(isset($where['paid']) && $where['paid'] !== '',function($query) use ($where){
$query->where('paid',$where['paid']);
})
->whereNotIn('activity_type',[30,31,32,33,34])
->whereNotIn('activity_type',[30,31,32,33,34,36,37,38])
->when(isset($where['paid']) && $where['paid'] !== '',function($query) use ($where){
$query->where('paid',$where['paid']);
})

View File

@ -90,9 +90,9 @@ class StoreOrderDao extends BaseDao
$isWithGoods = $where['is_with_goods'] ?? 0;
$activityType = $where['activity_type'] ?? 0;
if($isWithGoods == 1 || $activityType == 35){
$query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34]);
$query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,36,37,38]);
}else if($activityType == 0){
$query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,35]);
$query->whereNotIn('StoreOrder.activity_type',[20,30,31,32,33,34,35,36,37,38]);
}
$query->when(($sysDel !== null), function ($query) use ($sysDel) {

View File

@ -3121,6 +3121,11 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
$payMoney = abs((float)$payInfo['money']);
$merId = array_key_exists('mer_id',$payInfo) ? (int)$payInfo['mer_id'] : 0;
$uid = $user->uid;
// 判断:在线买单时 计算积分抵扣信息
$integralUse = $payInfo['integral_use'] ?? 0;
if($activityType == 30 && $integralUse > 0){
$payMoney -= $integralUse;
}
// 是否自购
$isSelfBuy = $user->is_promoter && systemConfig('extension_self') ? 1 : 0;
if($isSelfBuy){
@ -3166,6 +3171,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
'platform_coupon_price' => '',
'pay_type' => $payType,
'refund_switch' => 0,
'merchant_shareholder_integral' => $integralUse,
];
$groupOrder = [
'uid' => $uid,

View File

@ -65,7 +65,7 @@ class OnlinePay extends BaseController{
*/
public function createOrder(StoreOrderCreateRepository $orderCreateRepository){
// 参数获取
$payInfo = $this->request->params(['money','pay_type', 'mer_id', 'return_url']);
$payInfo = $this->request->params(['money','pay_type', 'mer_id', 'return_url','integral_use']);
if (!in_array($payInfo['pay_type'], StoreOrderRepository::PAY_TYPE, true)) return app('json')->fail('请选择正确的支付方式');
if ((float)$payInfo['money'] <= 0) return app('json')->fail('支付金额必须大于0');
if ((int)$payInfo['mer_id'] <= 0) return app('json')->fail('请选择商户!');

View File

@ -4,6 +4,7 @@ namespace app\listener\exchangeQuota;
use app\common\model\marketing\activity\Record;
use app\common\model\marketing\agent\AgentDelivery;
use app\common\model\system\merchant\MerchantShareholderIntegral;
use app\common\model\user\ExchangeIntegralRecord;
use app\common\model\user\ExchangeQuota;
use app\common\model\user\ExchangeQuotaRecord;
@ -280,6 +281,15 @@ class OrderPaySuccessEvent{
'source' => 0
];
}
// 是否存在餐费积分使用情况 存在则减少餐费积分
$useIntegral = $orderInfo->merchant_shareholder_integral ?? 0;
if($useIntegral > 0){
MerchantShareholderIntegral::where('status',1)
->where('uid','=',$orderInfo->uid)
->where('mer_id','=',$orderInfo->mer_id)
->inc('integral_use',$useIntegral)
->update();
}
}
// 修改用户持有
$userHoldInfo->save();

View File

@ -11,18 +11,18 @@ use crmeb\interfaces\ListenerInterface;
class ShareholderListen extends TimerService implements ListenerInterface{
public function handle($event): void{
$this->tick(1000 * 5, function () {
// Log::info('餐费积分定时任务被触发:');
$this->tick(1000 * 60 * 5, function () {
Log::info('餐费积分定时任务被触发:');
request()->clearCache();
try{
// 积分解冻 预计解冻时间小于当前时间,且状态为冻结中
MerchantShareholderIntegral::where('status',0)
->where('expect_thaw_time','<=',time())
->update(['status' => 1]);
->where('expect_thaw_time','<=', date("Y-m-d H:i:s"))
->update(['status' => 1,'real_thaw_time' => date("Y-m-d H:i:s", time())]);
// 积分过期 预计过期时间小于当前时间,且状态为使用中
MerchantShareholderIntegral::where('status',1)
->where('expect_overdue_time','<=',time())
->update(['status' => 2]);
->where('expect_overdue_time','<=', date("Y-m-d H:i:s"))
->update(['status' => 2,'real_overdue_time' => date("Y-m-d H:i:s", time())]);
}catch(\Exception $e){
Log::info('餐费积分定时任务 - 错误:' . $e->getMessage());
}