Commit a4346e07 authored by jianghaiming's avatar jianghaiming

Merge branch 'master' into clear_price_0816

parents d2279de7 eaeaa899
......@@ -1580,7 +1580,7 @@ class GoodsService
$goodsSku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]);
}
if (empty($goodsSku)) {
throw new GoodsException(["cus" => 15]);
return false;
}
if (!empty($marketingId)) {
......@@ -1596,11 +1596,9 @@ class GoodsService
}
}
}
PindanGoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
PindanGoodsSku::save(["total_amount_sold[+]" => $num], ["goods_sku_id" => $goodsSkuId]);
} else {
GoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num]
, ["goods_sku_id" => $goodsSkuId]);
GoodsSku::save(["total_amount_sold[+]" => $num], ["goods_sku_id" => $goodsSkuId]);
}
PaySuccessGoodsCallbackRecord::insertRecord([
......@@ -1623,7 +1621,7 @@ class GoodsService
);
}
return false;
throw new GoodsException(["cus" => 44]);
} else {
//同步到es
if (empty($marketingId)) {
......
......@@ -22,21 +22,26 @@ use App\Exception\custom\GoodsException;
class MarketingService
{
const ONLINE_LIFE_ACCOUNT_ID = "19019625839230981";
const ONLINE_LIFE_ACCOUNT_ID_TEST = "17963416161910792";
/**
* 写死的自营生活号
* @return string
*/
public static function getPublicLifeAccountId()
{
/**
$env = \Yaf\Application::app()->environ();
if (in_array($env, ['dev'])) {
$lifeAccountId = "13076446786650120";
} elseif (in_array($env, ['test'])) {
$lifeAccountId = "15559498695737346";
}else {
// $lifeAccountId = "19019625839230981";
$lifeAccountId = "17963416161910792";//测试用
// $lifeAccountId = self::ONLINE_LIFE_ACCOUNT_ID;
$lifeAccountId = self::ONLINE_LIFE_ACCOUNT_ID_TEST;//测试用
}
*/
$lifeAccountId = config('lifeaccount','life_account_id');
return $lifeAccountId;
}
......@@ -170,6 +175,10 @@ class MarketingService
$where['marketing_id'] = $params['marketing_id'];
}
$where['life_account_id'] = self::getPublicLifeAccountId();
if (!empty($params['online_status'])) {
if (is_array($params['online_status'])) {
foreach ($params['online_status'] as $key => $valu) {
......@@ -254,6 +263,8 @@ class MarketingService
$where["start_time[>]"] = $beforeSevenDay;
}
$where['life_account_id'] = self::getPublicLifeAccountId();
$where['ORDER'] = ["update_time" => "DESC"];
$where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
......@@ -285,6 +296,11 @@ class MarketingService
$lists[$key]["online_status_desc"] = Marketing::$onlineStatusDesc[$value["online_status"]];
if (!empty($priceData[$value["marketing_id"]])) {
$currentLifeAccountId = $priceData[$value["marketing_id"]]["publish_life_account_id"];
//小程序前端过滤掉线上测试生活号发布的活动
// if ($params['from'] == 1 && $currentLifeAccountId == self::ONLINE_LIFE_ACCOUNT_ID_TEST) {
// continue;
// }
$lists[$key]["publish_life_account_id"] = $currentLifeAccountId;
if (!empty($lifeAccountList[$currentLifeAccountId])) {
$lists[$key]["life_account_icon"] = $lifeAccountList[$currentLifeAccountId]["life_account_icon"];
......@@ -402,6 +418,8 @@ class MarketingService
throw new MarketingException(['cus'=>14]);
}
$lifeAccountId = config('lifeaccount','life_account_id');
$tmpMarketingId = [];
$tmpGoodsSkuId = [];
$goodsData = [
......@@ -465,6 +483,7 @@ class MarketingService
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'commission_mode' => $commissionMode,
'life_account_id' => $lifeAccountId,
];
$marketingId = Marketing::insertRecord($colums);
if (empty($marketingId)) {
......@@ -534,8 +553,8 @@ class MarketingService
$type = Marketing::MARKETING_TYPE_PINDAN;
$goodsSkuId = !empty($params['goods_sku_id']) ? explode(",", $params['goods_sku_id']) : [];
$takePlaceIds = !empty($params['take_place_ids']) ? explode(",", $params['take_place_ids']) : [];
$publicLifeAccountId = self::getPublicLifeAccountId();
//$publicLifeAccountId = self::getPublicLifeAccountId();
$lifeAccountId = config('lifeaccount','life_account_id');
if (empty($marketingName)) {
throw new MarketingException(['cus' => 0]);
}
......@@ -589,6 +608,7 @@ class MarketingService
'update_user_email' => $createUserEmail,
'update_time' => date("Y-m-d H:i:s"),
'create_time' => date("Y-m-d H:i:s"),
'life_account_id' => $lifeAccountId
];
$marketingId = Marketing::insertRecord($marketingParams);
if (empty($marketingId)) {
......@@ -598,7 +618,7 @@ class MarketingService
$pindanParams = [
"marketing_id" => $marketingId,
"publish_life_account_id" => $publicLifeAccountId,
"publish_life_account_id" => $lifeAccountId,
"pindan_pic" => $pindanPic,
"pindan_desc" => $pindanDesc,
"min_price" => $minPrice,
......
......@@ -145,7 +145,9 @@ class TakePlaceService
];
}
$where['ORDER'] = ['marketing_take_place_id' => 'DESC'];
$where['LIMIT'] = [$offset, $limit];
// 如果分页后排序,排序就会有问题,自提点数量有限也不用分页处理。
// $where['LIMIT'] = [$offset, $limit];
$relations = MarketingTakePlace::select('*', $where);
if(empty($relations)) {
......
......@@ -78,8 +78,8 @@ class Tcc2Service
if ($sku["online_status"] == GoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁
$rowCount = GoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] + $num,
"inventory_rest" => $sku["inventory_rest"] - $num,
"inventory_lock[+]" => $num,
"inventory_rest[-]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_rest[>=]" => $num]);
if ($rowCount <= 0) {
GoodsSku::rollback();
......@@ -125,8 +125,8 @@ class Tcc2Service
if ($sku["online_status"] == PindanGoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁
$rowCount = PindanGoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] + $num,
"inventory_rest" => $sku["inventory_rest"] - $num,
"inventory_lock[+]" => $num,
"inventory_rest[-]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_rest[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
......@@ -220,8 +220,8 @@ class Tcc2Service
//条件加上乐观锁
$rowCount = GoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num,
"total_amount_order" => $sku["total_amount_order"] + $num,
"inventory_lock[-]" => $num,
"total_amount_order[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_lock[>=]" => $num]);
if ($rowCount <= 0) {
GoodsSku::rollback();
......@@ -263,8 +263,8 @@ class Tcc2Service
if (!empty($sku["inventory_lock"]) && $sku["online_status"] == PindanGoodsSku::ONLINE_STATUS_ONLINE) {
//条件加上乐观锁
$rowCount = PindanGoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num,
"total_amount_order" => $sku["total_amount_order"] + $num,
"inventory_lock[-]" => $num,
"total_amount_order[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_lock[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
......@@ -303,11 +303,10 @@ class Tcc2Service
if (!empty($marketing) && $marketing["marketing_type"] == Marketing::MARKETING_TYPE_PINDAN) {
$marketingPindan = MarketingPindan::getRecord(["marketing_id" => $marketingId]);
if (!empty($marketingPindan)) {
MarketingPindan::save(["participate_number" => $marketingPindan["participate_number"] + $num]
, ["marketing_pindan_id" => $marketingPindan["marketing_pindan_id"]]);
MarketingPindan::save(["participate_number[+]" => $num], ["marketing_pindan_id" => $marketingPindan["marketing_pindan_id"]]);
}
PindanGoodsSku::save(["total_amount_sold" => $goodsSku["total_amount_sold"] + $num], ["goods_sku_id" => $goodsSkuId]);
PindanGoodsSku::save(["total_amount_sold[+]" => $num], ["goods_sku_id" => $goodsSkuId]);
}
}
......@@ -380,8 +379,8 @@ class Tcc2Service
//T时候执行C2,条件加上乐观锁
if ($tccInfo["status"] == Tcc::STATUS_T_SUCCESS) {
$rowCount = GoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num,
"inventory_rest" => $sku["inventory_rest"] + $num,
"inventory_lock[-]" => $num,
"inventory_rest[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_lock[>=]" => $num]);
if ($rowCount <= 0) {
GoodsSku::rollback();
......@@ -392,8 +391,8 @@ class Tcc2Service
//T时候执行C2,条件加上乐观锁
if ($tccInfo["status"] == Tcc::STATUS_C1_SUCCESS) {
$rowCount = GoodsSku::save([
"total_amount_order" => $sku["total_amount_order"] - $num,
"inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order[-]" => $num,
"inventory_rest[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "total_amount_order[>=]" => $num]);
if ($rowCount <= 0) {
GoodsSku::rollback();
......@@ -434,8 +433,8 @@ class Tcc2Service
//T时候执行C2,条件加上乐观锁
if ($tccInfo["status"] == Tcc::STATUS_T_SUCCESS) {
$rowCount = PindanGoodsSku::save([
"inventory_lock" => $sku["inventory_lock"] - $num,
"inventory_rest" => $sku["inventory_rest"] + $num,
"inventory_lock[-]" => $num,
"inventory_rest[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "inventory_lock[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
......@@ -446,8 +445,8 @@ class Tcc2Service
//T时候执行C2,条件加上乐观锁
if ($tccInfo["status"] == Tcc::STATUS_C1_SUCCESS) {
$rowCount = PindanGoodsSku::save([
"total_amount_order" => $sku["total_amount_order"] - $num,
"inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order[-]" => $num,
"inventory_rest[+]" => $num,
], ["goods_sku_id" => $goodsSkuId, "total_amount_order[>=]" => $num]);
if ($rowCount <= 0) {
PindanGoodsSku::rollback();
......@@ -514,13 +513,11 @@ class Tcc2Service
$goodsSkuId = $item["goods_sku_id"];
$num = $item["num"];
$sku = GoodsSku::getRecord(["goods_sku_id" => $goodsSkuId]
, ["goods_sku_id", "total_amount_order", "inventory_rest", "inventory_lock", "online_status"]);
$params = [
"inventory_rest" => $sku["inventory_rest"] + $num,
"total_amount_order" => $sku["total_amount_order"] - $num,
"inventory_rest[+]" => $num,
"total_amount_order[-]" => $num,
];
$rowCount = GoodsSku::save($params, ["goods_sku_id" => $goodsSkuId, "total_amount_order[>=]" => $num]);
$rowCount = GoodsSku::save($params, ["goods_sku_id" => $goodsSkuId]);
if ($rowCount <= 0) {
GoodsSku::rollback();
throw new GoodsException(["cus" => 32]);
......
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