feat: 修改订单逻辑和支付通知逻辑,并更新存储发送中的商品信息

This commit is contained in:
mkm 2024-06-13 09:35:33 +08:00
parent a37151676b
commit cf0520f1e6
3 changed files with 7 additions and 46 deletions

View File

@ -97,14 +97,11 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['old_cart_id'] = $v['id'];
$cart_select[$k]['cart_num'] = $v['cart_num'];
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
$cartInfo = $cart_select[$k];
$cartInfo['name'] = $find['store_name'];
$cartInfo['image'] = $find['image'];
//计算好vip价格
// $vipPrice = self::dealVip($find['price']);
// if ($vipPrice) {
// $cartInfo['price'] = $vipPrice;
// }
$cartInfo['vip_price'] = 0; //$cart_select[$k]['total'] - $vipPrice ?? 0;
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
$cart_select[$k]['branch_product_id'] = $find['branch_product_id'];
@ -120,45 +117,7 @@ class OrderLogic extends BaseLogic
}
//TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级
$pay_price = self::$pay_price;
// $check = StoreOrder::where('uid',\request()->userId)->count();//首单逻辑
$vipPrice = 0;
// if (isset($check) && $check['status'] == 1) {
// $discountRate = '0.99';//首单逻辑
// $pay_price 是价格
// $discountRate = $check['remark'];//折扣
// $discountRate = bcdiv($discountRate, '10', 2);
// $pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
// } else {
/* $userVip = User::where('id', \request()->userId)->value('user_ship');
if ($userVip) {
switch ($userVip) {
case UserShipEnum::VIP1:
$discountRate = UserShip::where('id', UserShipEnum::VIP1)->value('discount');
break;
case UserShipEnum::VIP2:
$discountRate = UserShip::where('id', UserShipEnum::VIP2)->value('discount');
break;
case UserShipEnum::VIP3:
$discountRate = UserShip::where('id', UserShipEnum::VIP3)->value('discount');
break;
case UserShipEnum::VIP4:
$discountRate = UserShip::where('id', UserShipEnum::VIP4)->value('discount');
break;
case UserShipEnum::VIP5:
$discountRate = UserShip::where('id', UserShipEnum::VIP5)->value('discount');
break;
default:
$discountRate = 1;
}
$discountRate = bcdiv($discountRate, '100', 2);
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
}*/
// }
// if (!empty(self::$total) && !empty($pay_price)) {
// bcscale(2);
// $vipPrice = bcsub(self::$total, $pay_price, 2);
// }
//成本价 收益
$order = [
'create_time' => time(),

View File

@ -125,9 +125,9 @@ class PayNotifyLogic extends BaseLogic
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
} else {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
Redis::send('push-platform-print', ['id' => $order['id']], 60);
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
}
Redis::send('push-platform-print', ['id' => $order['id']], 60);
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5);
}
@ -241,8 +241,8 @@ class PayNotifyLogic extends BaseLogic
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
} else {
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
Redis::send('push-platform-print', ['id' => $order['id']], 60);
}
Redis::send('push-platform-print', ['id' => $order['id']], 60);
return true;
}

View File

@ -45,8 +45,10 @@ class StoreStorageSend implements Consumer
'bar_code' => $find['bar_code'],
'cate_id' => $find['cate_id'],
'price' => $find['price'],
'unit' => $find['unit'],
'cost' => $find['cost'],
'vip_price' => $find['vip_price'],
'vip_ot_price' => $find['vip_ot_price'],
'unit' => $find['unit'],
'store_id' => $store_id,
'sales' => 0,
'stock' => 0,