Commit 1ce241b3 authored by pengfei's avatar pengfei

Merge branch 'colonel' into develop

parents bb177f27 aab21e3a
......@@ -17,6 +17,7 @@ use App\Models\marketing\mysql\Marketing;
use App\Models\user\mysql\UserWechatBind;
use App\Services\marketing\PindanActivityColonelConfigService;
use Api\PhpUtils\Log\JobLog;
use App\Services\marketing\ColonelService;
class ColonelorderController extends Job
{
......@@ -278,7 +279,7 @@ class ColonelorderController extends Job
if (!$url = config('interface', 'coupon.capitalpool.detail')) {
throw new Exception('没有capitalpool配置');
}
if (!$marketing = $this->getMarketingInfo()) {
if (!$marketing = ColonelService::getMarketingInfo()) {
throw new Exception('没有获取到资金池');
}
$httpParams = [
......@@ -314,29 +315,13 @@ class ColonelorderController extends Job
}
// 达到活动下线条件
if (self::ACTIVITY_OFFLINE_BALANCE >= $diffBalance) {
Marketing::updateRecord(['online_status' => Marketing::ONLINE_STATUS_GUANBI],
['marketing_id' => $marketing['marketing_id']]);
Marketing::updateRecord(
['online_status' => Marketing::ONLINE_STATUS_GUANBI],
['marketing_id' => $marketing['marketing_id']]
);
}
}
/**
* Notes: 获取团长分销活动
* User: pengfei@yidian-inc.com
* Date: 2021/9/9 6:06 下午
* @return array
*/
private function getMarketingInfo(): array
{
$where = [
'marketing_type' => Marketing::MARKETING_TYPE_TUANZHANG,
'ORDER' => ['marketing_id' => 'DESC'],
// 'online_status' => Marketing::ONLINE_STATUS_QIDONG TODO 待确认状态
];
$where['ORDER'] = ["create_time" => "DESC"];
$marketing = Marketing::getRecord($where, ['marketing_id', 'capital_pool_id']);
return (array)$marketing;
}
/**
* Notes: 加载配置
* User: pengfei@yidian-inc.com
......
......@@ -9,14 +9,28 @@ use App\Base\Job;
use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use Api\PhpUtils\Http\HttpUtil;
use Api\PhpUtils\Log\JobLog;
use App\Services\marketing\ColonelService;
class ColonelwalletController extends Job
{
const CAPITAL_POOL_ID = 2; // 资金池id
const CAPITAL_POOL_OP = 200; //200:团长奖励
const WALLET_SERVICE_NAME = 11; // 10生活圈优惠券,11营销活动
const WALLET_SERVICE_NAME = 10; // 10生活圈优惠券,11营销活动
const WALLET_SOURCE_NAME = 1; //使用方名,1生活圈,2主端
public $capitalPoolId = null;
/**
* Notes: 初始化-读取配置
* User: pengfei@yidian-inc.com
* Date: 2021/9/10 10:01 上午
*/
public function init()
{
parent::init();
$marketing = ColonelService::getMarketingInfo();
$this->capitalPoolId = $marketing['capital_pool_id'] ?? 0;
}
/**
* Notes: 奖励结算脚本
* User: pengfei@yidian-inc.com
......@@ -95,7 +109,7 @@ class ColonelwalletController extends Job
throw new Exception('没有grant_user_amount配置');
}
$httpParams = [
'capital_pool_id' => self::CAPITAL_POOL_ID
'capital_pool_id' => $this->capitalPoolId
];
$body = [];
foreach ($payInfoList as $payInfo) {
......@@ -110,6 +124,7 @@ class ColonelwalletController extends Job
}
$httpParams['body'] = $body;
$res = HttpUtil::post($url, $httpParams, 100000, 3);
$this->loggerInfo("url=$url,response:" . json_encode($res));
if ($res['code'] == 0 && isset($res['response']['result'])) {
$this->loggerInfo('调用资金池服务成功,count=' . count($payInfoList));
return true;
......@@ -187,8 +202,10 @@ class ColonelwalletController extends Job
*/
private function handlePayInfoStatus(array $payInfoIds): bool
{
$upStatus = ColonelDistributorPayInfo::updateRecord(['status' => ColonelDistributorPayInfo::STATUS_USE],
['pay_info_id' => $payInfoIds]);
$upStatus = ColonelDistributorPayInfo::updateRecord(
['status' => ColonelDistributorPayInfo::STATUS_USE],
['pay_info_id' => $payInfoIds]
);
if (empty($upStatus)) {
throw new Exception('更新pay_info状态失败.pay_info_ids=' . implode(',',$payInfoIds));
}
......
......@@ -11,6 +11,8 @@ use Api\PhpServices\Sensitive\Sensitive;
use Api\PhpUtils\Common\BaseConvert;
use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Http\HttpUtil;
use Api\PhpUtils\Lock\FrequencyLockUtil;
use Api\PhpUtils\Log\FileLog;
use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord;
......@@ -498,11 +500,13 @@ class MarketingPindanGoodsService
]);
$row = PindanGoodsSku::save([
"total_amount_sold" => $sku["total_amount_sold"] - $params["num"],
"total_amount_order" => $sku["total_amount_order"] - $params["num"],
"inventory_rest" => $sku["inventory_rest"] + $params["num"],
"total_amount_sold[-]" => $params["num"],
"total_amount_order[-]" => $params["num"],
"inventory_rest[+]" => $params["num"],
], ["goods_sku_id" => $sku["goods_sku_id"], "total_amount_sold[>=]" => $params["num"], "total_amount_order[>=]" => $params["num"]]);
FileLog::info('goods_refund_log', 'json decode error raw:' . json_encode($params));
if ($row < 1){
PindanGoodsSku::rollback();
GoodsRefundRecord::save([
......
......@@ -12,6 +12,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel;
use App\Models\marketing\mysql\ColonelDistributorColonelApply;
use App\Models\marketing\mysql\TakePlace;
use App\Models\user\mysql\UserWechatBind;
use App\Models\marketing\mysql\Marketing;
use Exception;
class ColonelService
......@@ -323,4 +324,21 @@ class ColonelService
$takePlaces = TakePlace::getRecords(['take_place_id' => $takePlaceId]);
return array_column((array)$takePlaces, null, 'take_place_id');
}
/**
* Notes: 获取团长分销活动
* User: pengfei@yidian-inc.com
* Date: 2021/9/9 6:06 下午
* @return array
*/
public static function getMarketingInfo(): array
{
$where = [
'marketing_type' => Marketing::MARKETING_TYPE_TUANZHANG,
'ORDER' => ['marketing_id' => 'DESC'],
];
$where['ORDER'] = ["create_time" => "DESC"];
$marketing = Marketing::getRecord($where, ['marketing_id', 'capital_pool_id']);
return (array)$marketing;
}
}
......@@ -3,6 +3,7 @@
namespace App\Services\tcc;
use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Log\FileLog;
use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku;
......@@ -491,7 +492,7 @@ class Tcc2Service
}
}
}
FileLog::info('goods_cancel_confirm_tcc', 'json decode error raw:' . $keys);
if ($isPindan) {
return self::pindanCancelConfirm($goodsInfoList);
} else {
......
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