|
|
@@ -897,6 +897,8 @@ class OrderController extends BaseController
|
|
|
* 复用 OrderService::createHdOrder,不改动 buy-item / create-order
|
|
|
* 整单优惠:会员折扣与门店满减互斥,只落地优惠金额更大的一项(相等用会员折扣)
|
|
|
* 秒杀商品已是活动价:seckillGoodsPrice 不计入会员折、门店满减金额基数,seckillGoodsNum 不计入满减件数门槛,仍计入应付和最低消费数量
|
|
|
+ * 跑腿费(runnerSendCost)不参与会员折/门店满减基数,折后原额计入应付
|
|
|
+ * 红包只抵商品金额:在加跑腿费/运费/包装费之前抵扣,抵扣额不超过商品合计,不抵运费
|
|
|
*/
|
|
|
public function actionCreateMixOrder()
|
|
|
{
|
|
|
@@ -1255,6 +1257,50 @@ class OrderController extends BaseController
|
|
|
// 含花材(含混合)按花材报价 goodsType=1;纯花束按 0
|
|
|
$quoteGoodsType = $hasItem ? 1 : 0;
|
|
|
|
|
|
+ // 红包(归属花店客户,与 buy-item 一致)
|
|
|
+ // 红包只抵商品金额:在加跑腿费/运费/包装费之前抵扣,抵扣额不超过商品合计,避免红包抵用运费
|
|
|
+ $hbId = $post['hbId'] ?? 0;
|
|
|
+ $hb = null;
|
|
|
+ if ($hbId > 0) {
|
|
|
+ $hb = HbClass::getById($hbId, true);
|
|
|
+ if (!empty($hb)) {
|
|
|
+ if ($hb->customId != $hdCustomId) {
|
|
|
+ util::fail('不是你的红包');
|
|
|
+ }
|
|
|
+ if ($hb->amount != $post['hbAmount']) {
|
|
|
+ util::fail('红包金额不相等');
|
|
|
+ }
|
|
|
+ if ($hb->status == 1) {
|
|
|
+ util::fail('红包已使用');
|
|
|
+ }
|
|
|
+ if ($hb->status == -1) {
|
|
|
+ util::fail('红包已作废');
|
|
|
+ }
|
|
|
+ if ($hb->endTime < time()) {
|
|
|
+ $hb->status = -1;
|
|
|
+ $hb->save();
|
|
|
+ util::fail('红包已失效');
|
|
|
+ }
|
|
|
+ if ($hb->beginTime > time()) {
|
|
|
+ util::fail('红包可使用期未到');
|
|
|
+ }
|
|
|
+ // 混合结算:按适用范围用商品明细校验最低消费(不含运费包装费)
|
|
|
+ HbScopeClass::assertMinConsume($hb, $resolvedProduct ?? [], $goodsOnlyPrice ?? $modifyPrice);
|
|
|
+ // 此时 $modifyPrice 仍为纯商品合计,红包抵扣额以其为上限
|
|
|
+ $hbDeduct = $hb->amount;
|
|
|
+ if (bccomp($hbDeduct, $modifyPrice, 2) > 0) {
|
|
|
+ $hbDeduct = $modifyPrice;
|
|
|
+ }
|
|
|
+ $modifyPrice = bcsub($modifyPrice, $hbDeduct, 2);
|
|
|
+ // 回写实际抵扣额:createHdOrder 以此核算原价 prePrice 与优惠额,保持口径一致
|
|
|
+ $post['hbAmount'] = $hbDeduct;
|
|
|
+ } else {
|
|
|
+ util::fail('红包无效');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 跑腿费(sendType=2 实际收取部分):不参与会员折/门店满减基数,随单传给折扣落地层剔除
|
|
|
+ $runnerSendCost = 0;
|
|
|
// 跑腿 style=2:按包运费花束 / 不包运费花束 / 纯花材满减 + 跑腿或自定义(异常兜底)
|
|
|
if (isset($post['sendType']) && (int)$post['sendType'] === 2) {
|
|
|
if ((int)$openIntraCity === 2) {
|
|
|
@@ -1368,6 +1414,7 @@ class OrderController extends BaseController
|
|
|
$post['sendDistance'] = $distanceMeters;
|
|
|
$post['freightSource'] = $freightSource;
|
|
|
$modifyPrice = bcadd($modifyPrice, $sendCost, 2);
|
|
|
+ $runnerSendCost = $sendCost;
|
|
|
}
|
|
|
|
|
|
if ($unMeetSendCost > 0) {
|
|
|
@@ -1379,40 +1426,6 @@ class OrderController extends BaseController
|
|
|
$modifyPrice = bcadd($modifyPrice, $packingFee, 2);
|
|
|
}
|
|
|
|
|
|
- // 红包(归属花店客户,与 buy-item 一致)
|
|
|
- $hbId = $post['hbId'] ?? 0;
|
|
|
- $hb = null;
|
|
|
- if ($hbId > 0) {
|
|
|
- $hb = HbClass::getById($hbId, true);
|
|
|
- if (!empty($hb)) {
|
|
|
- if ($hb->customId != $hdCustomId) {
|
|
|
- util::fail('不是你的红包');
|
|
|
- }
|
|
|
- if ($hb->amount != $post['hbAmount']) {
|
|
|
- util::fail('红包金额不相等');
|
|
|
- }
|
|
|
- if ($hb->status == 1) {
|
|
|
- util::fail('红包已使用');
|
|
|
- }
|
|
|
- if ($hb->status == -1) {
|
|
|
- util::fail('红包已作废');
|
|
|
- }
|
|
|
- if ($hb->endTime < time()) {
|
|
|
- $hb->status = -1;
|
|
|
- $hb->save();
|
|
|
- util::fail('红包已失效');
|
|
|
- }
|
|
|
- if ($hb->beginTime > time()) {
|
|
|
- util::fail('红包可使用期未到');
|
|
|
- }
|
|
|
- // 混合结算:按适用范围用商品明细校验最低消费(不含运费包装费)
|
|
|
- HbScopeClass::assertMinConsume($hb, $resolvedProduct ?? [], $goodsOnlyPrice ?? $modifyPrice);
|
|
|
- $modifyPrice = bcsub($modifyPrice, $hb->amount, 2);
|
|
|
- } else {
|
|
|
- util::fail('红包无效');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
$psMethodError = \bizHd\order\classes\PsMethodClass::checkLimit(
|
|
|
$this->shopId,
|
|
|
$this->mainId,
|
|
|
@@ -1444,10 +1457,13 @@ class OrderController extends BaseController
|
|
|
$post['hasSeckill'] = $hasSeckillGoods ? 1 : 0;
|
|
|
$post['seckillGoodsPrice'] = $seckillGoodsPrice;
|
|
|
$post['seckillGoodsNum'] = $seckillGoodsNum;
|
|
|
- // 互斥比较与落单使用同一口径:秒杀活动价不参与会员折和门店满减
|
|
|
+ // 跑腿费随单传给折扣落地层(createHdOrder 会员折 / addOrder 门店满减),从可折扣基数剔除
|
|
|
+ $post['runnerSendCost'] = $runnerSendCost;
|
|
|
+ // 互斥比较与落单使用同一口径:秒杀活动价、跑腿费不参与会员折和门店满减
|
|
|
+ $wholeDiscountPrice = bcsub($modifyPrice, $runnerSendCost, 2);
|
|
|
$wholeDiscountPrice = bcsub(
|
|
|
- $modifyPrice,
|
|
|
- HdOrderClass::capSeckillExcludePrice($seckillGoodsPrice, $modifyPrice),
|
|
|
+ $wholeDiscountPrice,
|
|
|
+ HdOrderClass::capSeckillExcludePrice($seckillGoodsPrice, $wholeDiscountPrice),
|
|
|
2
|
|
|
);
|
|
|
$wholeDiscountNum = bcsub($unMeetBigNum, $seckillGoodsNum, 2);
|