Commit 79941b45 authored by luhongguang's avatar luhongguang

update:商品支付回调调整

parent aade92c2
......@@ -21,10 +21,12 @@ use App\Models\goods\mysql\GoodsSnapshot;
use App\Models\goods\mysql\GoodsSpu;
use App\Models\goods\mysql\LifeAccountShopNum;
use App\Models\goods\mysql\PaySuccessGoodsCallbackRecord;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\Shop;
use App\Models\marketing\mysql\Distributor;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingGoods;
use App\Models\marketing\mysql\MarketingPindan;
use App\Models\shop\mysql\SubShop;
use App\Services\marketing\DistributorService;
use App\Services\marketing\MarketingGoodsService;
......@@ -1481,6 +1483,7 @@ class GoodsService
public static function paySuccessGoodsCallback($params = [])
{
$orderId = $params["order_id"];
$marketingId = empty($params["marketing_id"]) ? 0 : $params["marketing_id"];
$goodsPayInfos = json_decode($params["goods"], true);
GoodsSku::beginTransaction();
......@@ -1488,7 +1491,8 @@ class GoodsService
$record = PaySuccessGoodsCallbackRecord::getRecord([
"order_id" => $orderId,
"goods_sku_id" => $goodsSkuId,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS,
"marketing_id" => $marketingId]
);
if (empty($record)) {
$goodsSku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]);
......@@ -1496,14 +1500,32 @@ class GoodsService
throw new GoodsException(["cus" => 15]);
}
GoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
if (!empty($marketingId)) {
$marketing = Marketing::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketing) && $marketing["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$marketingPindan = MarketingPindan::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketingPindan)) {
$rowCount = MarketingPindan::save(["participate_number" => $marketingPindan["participate_number"] + $num]
, ["marketing_pindan_id" => $marketingPindan["marketing_pindan_id"]]);
if ($rowCount <= 0) {
GoodsSku::rollback();
return false;
}
}
}
PindanGoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
} else {
GoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
}
PaySuccessGoodsCallbackRecord::insertRecord([
"order_id" => $orderId,
"goods_sku_id" => $goodsSkuId,
"num" => $num,
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS]
"operator_result" => PaySuccessGoodsCallbackRecord::OPERATOR_RESULT_SUCCESS,
"marketing_id" => $marketingId]
);
}
}
......@@ -1521,8 +1543,10 @@ class GoodsService
return false;
} else {
//同步到es
foreach ($goodsPayInfos as $goodsSkuId => $num) {
self::updateGoodsInfoToEs($goodsSkuId);
if (empty($marketingId)) {
foreach ($goodsPayInfos as $goodsSkuId => $num) {
self::updateGoodsInfoToEs($goodsSkuId);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment