Commit c49394d4 authored by jianghaiming's avatar jianghaiming

Merge branch 'test' of https://gitlab.yidian-inc.com/bp/goods into test

parents 083e0ea6 6a66219b
...@@ -16,6 +16,8 @@ class GoodsException extends BaseException ...@@ -16,6 +16,8 @@ class GoodsException extends BaseException
const OTA_NOT_EXIST = 38; const OTA_NOT_EXIST = 38;
const RULE_LIMIT_ERROR = 50; const RULE_LIMIT_ERROR = 50;
const NOT_FIND_MARKETING = 51; const NOT_FIND_MARKETING = 51;
const LABEL_PRINTER_ALREADY_EXIST = 53;
const PRINTER_BIND_ERROR = 54;
protected $cus = [ protected $cus = [
0 => '商品创建失败,请稍后重试', 0 => '商品创建失败,请稍后重试',
...@@ -71,5 +73,7 @@ class GoodsException extends BaseException ...@@ -71,5 +73,7 @@ class GoodsException extends BaseException
self::RULE_LIMIT_ERROR => '单人可买上限填写错误', self::RULE_LIMIT_ERROR => '单人可买上限填写错误',
self::NOT_FIND_MARKETING => '找不到活动', self::NOT_FIND_MARKETING => '找不到活动',
52 => '过期时间不得小于等于上架开始时间', 52 => '过期时间不得小于等于上架开始时间',
self::LABEL_PRINTER_ALREADY_EXIST => '标签打印机已被%s绑定',
self::PRINTER_BIND_ERROR => '打印机绑定失败:%s',
]; ];
} }
\ No newline at end of file
...@@ -49,4 +49,19 @@ class BaseValidate extends Validate ...@@ -49,4 +49,19 @@ class BaseValidate extends Validate
return false; return false;
} }
} }
protected function isDate($value)
{
//匹配日期格式
if (preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $value, $parts)) {
//检测是否为日期
if (checkdate($parts[2], $parts[3], $parts[1])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
} }
\ No newline at end of file
...@@ -5,12 +5,12 @@ namespace Validate; ...@@ -5,12 +5,12 @@ namespace Validate;
class ColonelConfigValidate extends BaseValidate class ColonelConfigValidate extends BaseValidate
{ {
protected $rule = [ protected $rule = [
'date' => 'require', 'date' => 'require|isDate',
'config' => 'require', 'config' => 'require',
]; ];
protected $message = [ protected $message = [
'date' => 'date 参数不能为空', 'date' => 'date 参数格式错误',
'config' => 'config 参数不能为空', 'config' => 'config 参数不能为空',
'marketing_id' => 'marketing_id 参数不能为空', 'marketing_id' => 'marketing_id 参数不能为空',
]; ];
......
...@@ -14,6 +14,10 @@ class OtaValidate extends \Validate\BaseValidate ...@@ -14,6 +14,10 @@ class OtaValidate extends \Validate\BaseValidate
protected $rule = [ protected $rule = [
'ota_name' => 'require', 'ota_name' => 'require',
'ota_id' => 'require', 'ota_id' => 'require',
'address' => 'require',
'location' => 'require',
'longitude' => 'require',
'latitude' => 'require',
'offset' => 'egt:0', 'offset' => 'egt:0',
'limit' => 'elt:100', 'limit' => 'elt:100',
]; ];
...@@ -22,6 +26,10 @@ class OtaValidate extends \Validate\BaseValidate ...@@ -22,6 +26,10 @@ class OtaValidate extends \Validate\BaseValidate
protected $message = [ protected $message = [
"ota_name" => "供应商名称不能为空", "ota_name" => "供应商名称不能为空",
"ota_id" => "ota_id不能为空", "ota_id" => "ota_id不能为空",
"address" => "详细地址不能为空",
"location" => "高德地图详细地址不能为空",
"longitude" => "经度不能为空",
"latitude" => "纬度不能为空",
"offset" => "偏移量不能小于0", "offset" => "偏移量不能小于0",
"limit" => "单次不能大于100条", "limit" => "单次不能大于100条",
]; ];
...@@ -34,7 +42,7 @@ class OtaValidate extends \Validate\BaseValidate ...@@ -34,7 +42,7 @@ class OtaValidate extends \Validate\BaseValidate
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(['ota_name']); return $this->only(['ota_name', 'address','longitude','latitude', 'location']);
} }
public function sceneDelete() public function sceneDelete()
{ {
...@@ -43,7 +51,7 @@ class OtaValidate extends \Validate\BaseValidate ...@@ -43,7 +51,7 @@ class OtaValidate extends \Validate\BaseValidate
public function sceneUpdate() public function sceneUpdate()
{ {
return $this->only(['ota_id']); return $this->only(['ota_id', 'ota_name', 'address','longitude','latitude', 'location']);
} }
public function sceneListByIds() public function sceneListByIds()
{ {
......
...@@ -19,7 +19,7 @@ class ColonelDistributorColonelApply extends MysqlBase ...@@ -19,7 +19,7 @@ class ColonelDistributorColonelApply extends MysqlBase
const STATUS_PASS = 1;//审核通过 const STATUS_PASS = 1;//审核通过
const STATUS_REJECT = 2;//审核驳回 const STATUS_REJECT = 2;//审核驳回
const DEFAULT_COLUMN = ['colonel_apply_id','audit_status','user_id','phone','contact_name','take_place_name','province','city','area','location']; const DEFAULT_COLUMN = ['colonel_apply_id','audit_status','user_id','phone','contact_name','take_place_name','province','city','area','location','address'];
public static function insertRecord(array $column) : int public static function insertRecord(array $column) : int
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Models\marketing\mysql; namespace App\Models\marketing\mysql;
use Api\PhpUtils\Mysql\MysqlBase; use Api\PhpUtils\Mysql\MysqlBase;
use App\Services\marketing\MarketingService;
/** /**
* 自提点 * 自提点
...@@ -25,7 +26,7 @@ class TakePlace extends MysqlBase ...@@ -25,7 +26,7 @@ class TakePlace extends MysqlBase
*/ */
public static function searchList($params) public static function searchList($params)
{ {
$lifeAccountId = $params['life_account_id'] ?? 0; $lifeAccountId = $params['life_account_id'] ?? MarketingService::getPublicLifeAccountId();
$keywords = $params['keywords'] ?? ''; $keywords = $params['keywords'] ?? '';
$offset = $params['offset'] ?? 0; $offset = $params['offset'] ?? 0;
$limit = $params['limit'] ?? 20; $limit = $params['limit'] ?? 20;
...@@ -59,6 +60,11 @@ class TakePlace extends MysqlBase ...@@ -59,6 +60,11 @@ class TakePlace extends MysqlBase
return self::get($column, $where); return self::get($column, $where);
} }
public static function getRecords(array $where, $column = '*')
{
return self::select($column, $where);
}
public static function existTakePlaceName(string $takePlaceName) : bool public static function existTakePlaceName(string $takePlaceName) : bool
{ {
$exist = self::getRecord(['take_place_name' => $takePlaceName], ['take_place_id']); $exist = self::getRecord(['take_place_name' => $takePlaceName], ['take_place_id']);
......
...@@ -22,9 +22,11 @@ class OtaController extends Base ...@@ -22,9 +22,11 @@ class OtaController extends Base
$name = $this->params['ota_name'] ?? ''; $name = $this->params['ota_name'] ?? '';
$printerSn = $this->params['printer_sn'] ?? ''; $printerSn = $this->params['printer_sn'] ?? '';
$printerKey = $this->params['printer_key'] ?? ''; $printerKey = $this->params['printer_key'] ?? '';
$labelPrinterSn = $this->params['label_printer_sn'] ?? '';
$labelPrinterKey = $this->params['label_printer_key'] ?? '';
$offset = $this->params['offset'] ?? 0; $offset = $this->params['offset'] ?? 0;
$limit = $this->params['limit'] ?? 20; $limit = $this->params['limit'] ?? 20;
$res = OtaService::list($name, $printerSn, $printerKey, $offset, $limit); $res = OtaService::list($name, $printerSn, $printerKey,$labelPrinterSn, $labelPrinterKey, $offset, $limit);
$this->success(['result' => $res]); $this->success(['result' => $res]);
} }
......
...@@ -13,15 +13,18 @@ use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum; ...@@ -13,15 +13,18 @@ use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum;
use App\Models\marketing\mysql\ColonelDistributorPayInfo; use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use App\Exception\custom\InterfaceException; use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\HttpUtil; use Api\PhpUtils\Http\HttpUtil;
use App\Models\marketing\mysql\Marketing;
use App\Models\user\mysql\UserWechatBind; use App\Models\user\mysql\UserWechatBind;
use App\Services\marketing\PindanActivityColonelConfigService; use App\Services\marketing\PindanActivityColonelConfigService;
use Api\PhpUtils\Log\JobLog; use Api\PhpUtils\Log\JobLog;
use App\Services\marketing\ColonelService;
class ColonelorderController extends Job class ColonelorderController extends Job
{ {
const REWARD_UNIT = 100; // 奖励单位: 分 const REWARD_UNIT = 100; // 奖励单位: 分
const INVITE_NEW_USER_REWARD = 3 * self::REWARD_UNIT; // 邀请新用户奖励 const INVITE_NEW_USER_REWARD = 3 * self::REWARD_UNIT; // 邀请新用户奖励
const DEFAULT_USER_BATCH_SIZE = 100; // 批量处理数据条数 const DEFAULT_USER_BATCH_SIZE = 100; // 批量处理数据条数
const ACTIVITY_OFFLINE_BALANCE = 50 * self::REWARD_UNIT; // 活动余额下线阈值
public $colonelConfigList; // 活动配置 public $colonelConfigList; // 活动配置
public $settlementDate; // 活动结算日 public $settlementDate; // 活动结算日
...@@ -36,10 +39,7 @@ class ColonelorderController extends Job ...@@ -36,10 +39,7 @@ class ColonelorderController extends Job
public function init() public function init()
{ {
parent::init(); parent::init();
$timeRange = PindanActivityColonelConfigService::getSettlementTimeRange(); $this->loadTimeConfig();
$this->settlementDate = $timeRange['date'];
$this->startTime = $timeRange['start_time'];
$this->endTime = $timeRange['end_time'];
$this->colonelConfigList = $this->getColonelConfig($this->settlementDate); $this->colonelConfigList = $this->getColonelConfig($this->settlementDate);
} }
...@@ -62,6 +62,7 @@ class ColonelorderController extends Job ...@@ -62,6 +62,7 @@ class ColonelorderController extends Job
if (!empty($colonelPayInfoData)) { if (!empty($colonelPayInfoData)) {
try { try {
$this->loggerInfo('colonelPayInfoCount=' . count($colonelPayInfoData)); $this->loggerInfo('colonelPayInfoCount=' . count($colonelPayInfoData));
$this->handleMarketingBalance($colonelPayInfoData);
$colonelPayInfoData = $this->getFormatPayInfoData($colonelPayInfoData); $colonelPayInfoData = $this->getFormatPayInfoData($colonelPayInfoData);
$this->handleSavePayInfo($colonelPayInfoData); $this->handleSavePayInfo($colonelPayInfoData);
$this->loggerInfo('success'); $this->loggerInfo('success');
...@@ -204,7 +205,6 @@ class ColonelorderController extends Job ...@@ -204,7 +205,6 @@ class ColonelorderController extends Job
if (empty($url)) { if (empty($url)) {
throw new InterfaceException(['cus' => 0]); throw new InterfaceException(['cus' => 0]);
} }
$res = HttpUtil::get($url, $res = HttpUtil::get($url,
['user_ids' => $userIds, 'start_time' => $startTime, 'end_time' => $endTime]); ['user_ids' => $userIds, 'start_time' => $startTime, 'end_time' => $endTime]);
if (!empty($res['response']['result'])) { if (!empty($res['response']['result'])) {
...@@ -267,6 +267,83 @@ class ColonelorderController extends Job ...@@ -267,6 +267,83 @@ class ColonelorderController extends Job
return (int)ColonelDistributorPayInfo::save($data); return (int)ColonelDistributorPayInfo::save($data);
} }
/**
* Notes: 获取团长分销资余额
* User: pengfei@yidian-inc.com
* Date: 2021/9/9 6:19 下午
* @return array
* @throws Exception
*/
private function getMarketingCapitalPoolBalance(): array
{
if (!$url = config('interface', 'coupon.capitalpool.detail')) {
throw new Exception('没有capitalpool配置');
}
if (!$marketing = ColonelService::getMarketingInfo()) {
throw new Exception('没有获取到资金池');
}
$httpParams = [
'capital_pool_id' => $marketing['capital_pool_id']
];
$response = HttpUtil::post($url, $httpParams, 100000, 3);
$this->loggerInfo("url=$url,request=" . json_encode($httpParams) . ";response=" . json_encode($response));
if (!isset($response['response']['result']['capital_pool_total'])) {
throw new Exception('没有获取到资金池信息');
}
$result = $response['response']['result'];
$balance = ($result['capital_pool_total'] - $result['capital_pool_lock'] - $result['capital_pool_used']);
return [
'marketing_id' => $marketing['marketing_id'],
'balance' => $balance
];
}
/**
* Notes: 检测资金余额,是否下线活动
* User: pengfei@yidian-inc.com
* Date: 2021/9/9 6:29 下午
* @param $colonelPayInfoData
* @throws Exception
*/
private function handleMarketingBalance($colonelPayInfoData)
{
$totalReward = array_sum(array_column($colonelPayInfoData, 'reward'));
$marketing = $this->getMarketingCapitalPoolBalance();
$diffBalance = $marketing['balance'] - $totalReward;
if (0 >= $diffBalance) {
throw new Exception('资金池可用余额不足');
}
// 达到活动下线条件
if (self::ACTIVITY_OFFLINE_BALANCE >= $diffBalance) {
Marketing::updateRecord(
['online_status' => Marketing::ONLINE_STATUS_GUANBI],
['marketing_id' => $marketing['marketing_id']]
);
}
}
/**
* Notes: 加载配置
* User: pengfei@yidian-inc.com
* Date: 2021/9/8 7:43 下午
*/
private function loadTimeConfig()
{
// 如果传入时间-使用指定时间
$params = $this->getRequest()->getParams();
if (empty($params['date']) || !strtotime($params['date'])) {
$timeRange = PindanActivityColonelConfigService::getSettlementTimeRange();
$this->settlementDate = $timeRange['date'];
$this->startTime = $timeRange['start_time'];
$this->endTime = $timeRange['end_time'];
} else {
$hour = PindanActivityColonelConfigService::ACTIVITY_DEFAULT_HOUR;
$this->settlementDate = $params['date'];
$this->startTime = "{$params['date']} $hour:00:00";
$this->endTime = date('Y-m-d H:i:s', strtotime($this->startTime . ' +1 day'));
}
}
/** /**
* Notes: 记录 info 日志 * Notes: 记录 info 日志
* User: pengfei@yidian-inc.com * User: pengfei@yidian-inc.com
......
...@@ -7,22 +7,34 @@ ...@@ -7,22 +7,34 @@
use App\Base\Job; use App\Base\Job;
use App\Models\marketing\mysql\ColonelDistributorPayInfo; use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\HttpUtil; use Api\PhpUtils\Http\HttpUtil;
use Api\PhpUtils\Log\JobLog; use Api\PhpUtils\Log\JobLog;
use App\Services\marketing\ColonelService;
class ColonelwalletController extends Job class ColonelwalletController extends Job
{ {
const CAPITAL_POOL_ID = 2; // 资金池id
const CAPITAL_POOL_OP = 200; //200:团长奖励 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主端 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: 奖励结算脚本 * Notes: 奖励结算脚本
* User: pengfei@yidian-inc.com * User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:03 下午 * Date: 2021/9/9 11:17 上午
* @throws InterfaceException
*/ */
public function indexAction() public function indexAction()
{ {
...@@ -30,14 +42,15 @@ class ColonelwalletController extends Job ...@@ -30,14 +42,15 @@ class ColonelwalletController extends Job
$payInfoList = $this->getPayInfoList(); $payInfoList = $this->getPayInfoList();
$this->loggerInfo('payInfoCount=' . count($payInfoList)); $this->loggerInfo('payInfoCount=' . count($payInfoList));
if (!empty($payInfoList)) { if (!empty($payInfoList)) {
if ($this->deductingInventory($payInfoList)) { try {
if ($this->toWallet($payInfoList)) { if ($this->deductingInventory($payInfoList)) {
if ($this->handlePayInfoStatus(array_column($payInfoList, 'pay_info_id'))) { if ($this->toWallet($payInfoList)) {
$this->loggerInfo('success'); $this->handlePayInfoStatus(array_column($payInfoList, 'pay_info_id'));
} else {
$this->loggerError('更新状态失败');
} }
} }
$this->loggerInfo('success');
} catch (Exception $e) {
$this->loggerError('error:' . $e->getMessage());
} }
} }
$this->loggerInfo('end'); $this->loggerInfo('end');
...@@ -49,12 +62,12 @@ class ColonelwalletController extends Job ...@@ -49,12 +62,12 @@ class ColonelwalletController extends Job
* Date: 2021/9/3 6:04 下午 * Date: 2021/9/3 6:04 下午
* @param $payInfoList * @param $payInfoList
* @return bool * @return bool
* @throws InterfaceException * @throws Exception
*/ */
private function toWallet($payInfoList): bool private function toWallet($payInfoList): bool
{ {
if (!$url = config('interface', 'wallet.account.transfer')) { if (!$url = config('interface', 'wallet.account.transfer')) {
throw new InterfaceException(['cus' => 0]); throw new Exception('没有wallet.account.transfer配置');
} }
$httpParams = self::getWalletHttpParams(); $httpParams = self::getWalletHttpParams();
$list = []; $list = [];
...@@ -67,7 +80,7 @@ class ColonelwalletController extends Job ...@@ -67,7 +80,7 @@ class ColonelwalletController extends Job
'third_order_id_type' => $payInfo['type'], 'third_order_id_type' => $payInfo['type'],
'third_order_desc' => self::getThirdOrderDesc($payInfo), 'third_order_desc' => self::getThirdOrderDesc($payInfo),
'amount' => $payInfo['reward'], 'amount' => $payInfo['reward'],
'extra' => $payInfo 'extra' => ''
]; ];
} }
$httpParams['list'] = $list; $httpParams['list'] = $list;
...@@ -77,8 +90,7 @@ class ColonelwalletController extends Job ...@@ -77,8 +90,7 @@ class ColonelwalletController extends Job
$this->loggerInfo('调用钱包服务成功,count=' . count($payInfoList)); $this->loggerInfo('调用钱包服务成功,count=' . count($payInfoList));
return true; return true;
} else { } else {
$this->loggerError('调用钱包服务失败,httpParams=' . json_encode($httpParams)); throw new Exception('调用钱包服务失败,httpParams=' . json_encode($httpParams));
return false;
} }
} }
...@@ -89,15 +101,15 @@ class ColonelwalletController extends Job ...@@ -89,15 +101,15 @@ class ColonelwalletController extends Job
* Date: 2021/9/3 6:04 下午 * Date: 2021/9/3 6:04 下午
* @param $payInfoList * @param $payInfoList
* @return bool * @return bool
* @throws InterfaceException * @throws Exception
*/ */
private function deductingInventory($payInfoList): bool private function deductingInventory($payInfoList): bool
{ {
if (!$url = config('interface', 'coupon.capitalpool.grant_user_amount')) { if (!$url = config('interface', 'coupon.capitalpool.grant_user_amount')) {
throw new InterfaceException(['cus' => 0]); throw new Exception('没有grant_user_amount配置');
} }
$httpParams = [ $httpParams = [
'capital_pool_id' => self::CAPITAL_POOL_ID 'capital_pool_id' => $this->capitalPoolId
]; ];
$body = []; $body = [];
foreach ($payInfoList as $payInfo) { foreach ($payInfoList as $payInfo) {
...@@ -117,8 +129,7 @@ class ColonelwalletController extends Job ...@@ -117,8 +129,7 @@ class ColonelwalletController extends Job
$this->loggerInfo('调用资金池服务成功,count=' . count($payInfoList)); $this->loggerInfo('调用资金池服务成功,count=' . count($payInfoList));
return true; return true;
} else { } else {
$this->loggerError('调用资金池服务失败,httpParams=' . json_encode($httpParams)); throw new Exception('调用资金池服务失败,httpParams=' . json_encode($httpParams));
return false;
} }
} }
...@@ -180,17 +191,25 @@ class ColonelwalletController extends Job ...@@ -180,17 +191,25 @@ class ColonelwalletController extends Job
return $desc; return $desc;
} }
/** /**
* Notes: 修改状态 * Notes: 修改状态
* User: pengfei@yidian-inc.com * User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:09 下 * Date: 2021/9/9 11:15 上
* @param array $payInfoIds * @param array $payInfoIds
* @return bool * @return bool
* @throws Exception
*/ */
private function handlePayInfoStatus(array $payInfoIds): bool private function handlePayInfoStatus(array $payInfoIds): bool
{ {
return ColonelDistributorPayInfo::updateRecord(['status' => ColonelDistributorPayInfo::STATUS_USE], $upStatus = ColonelDistributorPayInfo::updateRecord(
['pay_info_id' => $payInfoIds]); ['status' => ColonelDistributorPayInfo::STATUS_USE],
['pay_info_id' => $payInfoIds]
);
if (empty($upStatus)) {
throw new Exception('更新pay_info状态失败.pay_info_ids=' . implode(',',$payInfoIds));
}
return $upStatus;
} }
/** /**
......
...@@ -187,7 +187,7 @@ class MarketingController extends Base ...@@ -187,7 +187,7 @@ class MarketingController extends Base
$this->params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐 $this->params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐
$this->params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期 $this->params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期
$this->params['from'] = 1;//1 小程序前台 默认0 后台 $this->params['from'] = 1;//1 小程序前台 默认0 后台
//正在进行中的 //正在进行中的 按结束时间正序
$this->params['sort_field'] = 'end_time'; $this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'asc'; $this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false; $this->params['need_buy_num'] = false;
...@@ -196,9 +196,9 @@ class MarketingController extends Base ...@@ -196,9 +196,9 @@ class MarketingController extends Base
$list['doing'] = $list['doing'] ? array_column($list['doing'], null, 'marketing_id') : []; $list['doing'] = $list['doing'] ? array_column($list['doing'], null, 'marketing_id') : [];
$marketingIdsDoing = array_keys($list['doing']); $marketingIdsDoing = array_keys($list['doing']);
//当天即将开始的 //当天即将开始的 按开始时间正序
$this->params['page'] = 1; $this->params['page'] = 1;
$this->params['sort_field'] = 'end_time'; $this->params['sort_field'] = 'start_time';
$this->params['sort_type'] = 'asc'; $this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false; $this->params['need_buy_num'] = false;
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_START_TODAY;//1 未开始,2进行中,3已结束, 4当日上新(即将开始) $this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_START_TODAY;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
...@@ -206,7 +206,7 @@ class MarketingController extends Base ...@@ -206,7 +206,7 @@ class MarketingController extends Base
$list['prepare'] = $list['prepare'] ? array_column((array)$list['prepare'], null, 'marketing_id') : []; $list['prepare'] = $list['prepare'] ? array_column((array)$list['prepare'], null, 'marketing_id') : [];
$marketingIdsPrepare = array_keys($list['prepare']); $marketingIdsPrepare = array_keys($list['prepare']);
//已结束的 //已结束的 按结束时间倒序
$this->params['page'] = 1; $this->params['page'] = 1;
$this->params['page_size'] = 10; $this->params['page_size'] = 10;
$this->params['sort_field'] = 'end_time'; $this->params['sort_field'] = 'end_time';
......
...@@ -11,6 +11,8 @@ use Api\PhpServices\Sensitive\Sensitive; ...@@ -11,6 +11,8 @@ use Api\PhpServices\Sensitive\Sensitive;
use Api\PhpUtils\Common\BaseConvert; use Api\PhpUtils\Common\BaseConvert;
use Api\PhpUtils\Common\GoodsSkuId; use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Http\HttpUtil; use Api\PhpUtils\Http\HttpUtil;
use Api\PhpUtils\Lock\FrequencyLockUtil;
use Api\PhpUtils\Log\FileLog;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Category; use App\Models\goods\mysql\Category;
use App\Models\goods\mysql\GoodsOperationRecord; use App\Models\goods\mysql\GoodsOperationRecord;
...@@ -498,11 +500,13 @@ class MarketingPindanGoodsService ...@@ -498,11 +500,13 @@ class MarketingPindanGoodsService
]); ]);
$row = PindanGoodsSku::save([ $row = PindanGoodsSku::save([
"total_amount_sold" => $sku["total_amount_sold"] - $params["num"], "total_amount_sold[-]" => $params["num"],
"total_amount_order" => $sku["total_amount_order"] - $params["num"], "total_amount_order[-]" => $params["num"],
"inventory_rest" => $sku["inventory_rest"] + $params["num"], "inventory_rest[+]" => $params["num"],
], ["goods_sku_id" => $sku["goods_sku_id"], "total_amount_sold[>=]" => $params["num"], "total_amount_order[>=]" => $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){ if ($row < 1){
PindanGoodsSku::rollback(); PindanGoodsSku::rollback();
GoodsRefundRecord::save([ GoodsRefundRecord::save([
......
...@@ -4,10 +4,11 @@ namespace App\Services\goods; ...@@ -4,10 +4,11 @@ namespace App\Services\goods;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\Ota; use App\Models\goods\mysql\Ota;
use Api\PhpServices\Printer\PrinterFactory;
class OtaService class OtaService
{ {
const COLUMNS = ['ota_id','ota_name','printer_sn','printer_key']; const COLUMNS = ['ota_id','ota_name','printer_sn','printer_key','label_printer_sn','label_printer_key', 'longitude', 'latitude', 'location', 'address', 'status'];
/** /**
* 获取供应商列表(op 后台) * 获取供应商列表(op 后台)
* @param string $otaName * @param string $otaName
...@@ -17,13 +18,15 @@ class OtaService ...@@ -17,13 +18,15 @@ class OtaService
* @param int $limit * @param int $limit
* @return \Api\PhpUtils\Mysql\MysqlBase * @return \Api\PhpUtils\Mysql\MysqlBase
*/ */
public static function list($otaName='',$printerSN='',$printerKey='',$offset=0,$limit=20) public static function list($otaName='',$printerSN='',$printerKey='', $labelPrinterSN='',$labelPrinterKey='',$offset=0,$limit=20)
{ {
$otaName && $where['ota_name'] = $otaName; $otaName && $where['ota_name'] = $otaName;
$printerSN && $where["printer_sn"] = $printerSN; $printerSN && $where["printer_sn"] = $printerSN;
$printerKey && $where['printer_key'] = $printerKey; $printerKey && $where['printer_key'] = $printerKey;
$labelPrinterSN && $where["label_printer_sn"] = $labelPrinterSN;
$labelPrinterKey && $where['label_printer_key'] = $labelPrinterKey;
$where['status'] = Ota::STATUS_NORMAL; // $where['status'] = Ota::STATUS_NORMAL;
$where['ORDER'] = ['ota_id' => 'DESC']; $where['ORDER'] = ['ota_id' => 'DESC'];
$where['LIMIT'] = [$offset, $limit]; $where['LIMIT'] = [$offset, $limit];
...@@ -82,10 +85,52 @@ class OtaService ...@@ -82,10 +85,52 @@ class OtaService
); );
} }
} }
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['label_printer_sn']) && $params['label_printer_sn']) {
$printer = self::list('','', '', $params['label_printer_sn']);
if ($printer['total'] > 0) {
throw new GoodsException(
['cus' => GoodsException::LABEL_PRINTER_ALREADY_EXIST,'data'=>[$printer['list'][0]['ota_name']]]
);
}
}
try {
if(isset($params['printer_sn']) && $params['printer_sn']) {
$FeiPrinter = PrinterFactory::getPrinter('Fei');
$FeiPrinter->addPrinter([
'printer_sn' => $params['printer_sn'],
'printer_key' => $params['printer_key'],
'ota_name' => $params['ota_name'],
]);
}
if(isset($params['label_printer_sn']) && $params['label_printer_sn']) {
$FeiPrinter = PrinterFactory::getPrinter('Fei');
$FeiPrinter->addPrinter([
'printer_sn' => $params['label_printer_sn'],
'printer_key' => $params['label_printer_key'],
'ota_name' => $params['ota_name'],
]);
}
} catch (\Exception $e) {
throw new GoodsException(
['cus' => GoodsException::PRINTER_BIND_ERROR,'data'=>[$e->getMessage()]]
);
}
$data['ota_name'] = $params['ota_name']; $data['ota_name'] = $params['ota_name'];
$data['printer_sn'] = $params['printer_sn'] ?? ''; $data['printer_sn'] = $params['printer_sn'] ?? '';
$data['printer_key'] = $params['printer_key'] ?? ''; $data['printer_key'] = $params['printer_key'] ?? '';
$data['label_printer_sn'] = $params['label_printer_sn'] ?? '';
$data['label_printer_key'] = $params['label_printer_key'] ?? '';
$data['longitude'] = $params['longitude'];
$data['latitude'] = $params['latitude'];
$data['location'] = $params['location'];
$data['address'] = $params['address'];
return Ota::insert($data); return Ota::insert($data);
} }
...@@ -108,13 +153,40 @@ class OtaService ...@@ -108,13 +153,40 @@ class OtaService
*/ */
public static function update($params) public static function update($params)
{ {
if(empty($params['ota_id'])) { if(empty($params['ota_id'])) {
throw new GoodsException(['cus' => GoodsException::EMPTY_OTA_ID]); throw new GoodsException(['cus' => GoodsException::EMPTY_OTA_ID]);
} }
$otaDetail = self::detail($params['ota_id']);
//检查供应商是否存在 //检查供应商是否存在
if (empty(self::detail($params['ota_id']))) { if (empty($otaDetail)) {
throw new GoodsException(['cus' => GoodsException::OTA_NOT_EXIST]); throw new GoodsException(['cus' => GoodsException::OTA_NOT_EXIST]);
} }
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['printer_sn']) && $params['printer_sn']) {
$printer = self::list('',$params['printer_sn']);
if ($printer['total'] > 0) {
throw new GoodsException(
['cus' => GoodsException::PRINTER_ALREADY_EXIST,'data'=>[$printer['list'][0]['ota_name']]]
);
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['label_printer_sn']) && $params['label_printer_sn']) {
$printer = self::list('','', '', $params['label_printer_sn']);
if ($printer['total'] > 0) {
throw new GoodsException(
['cus' => GoodsException::LABEL_PRINTER_ALREADY_EXIST,'data'=>[$printer['list'][0]['ota_name']]]
);
}
}
$data = []; $data = [];
isset($params['ota_name']) && $data['ota_name'] = $params['ota_name']; isset($params['ota_name']) && $data['ota_name'] = $params['ota_name'];
isset($params['printer_sn']) && $data['printer_sn'] = $params['printer_sn']; isset($params['printer_sn']) && $data['printer_sn'] = $params['printer_sn'];
......
...@@ -12,6 +12,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel; ...@@ -12,6 +12,7 @@ use App\Models\marketing\mysql\ColonelDistributorColonel;
use App\Models\marketing\mysql\ColonelDistributorColonelApply; use App\Models\marketing\mysql\ColonelDistributorColonelApply;
use App\Models\marketing\mysql\TakePlace; use App\Models\marketing\mysql\TakePlace;
use App\Models\user\mysql\UserWechatBind; use App\Models\user\mysql\UserWechatBind;
use App\Models\marketing\mysql\Marketing;
use Exception; use Exception;
class ColonelService class ColonelService
...@@ -49,11 +50,11 @@ class ColonelService ...@@ -49,11 +50,11 @@ class ColonelService
$colonelData['take_place_name'] = "【团长】{$colonelData['take_place_name']}"; $colonelData['take_place_name'] = "【团长】{$colonelData['take_place_name']}";
} }
if (!$applyId = ColonelDistributorColonelApply::insertRecord($colonelData)) { if (!$applyId = ColonelDistributorColonelApply::insertRecord($colonelData)) {
throw new MarketingException(MarketingException::COLONEL_APPLY_FAILED); throw new Exception(MarketingException::COLONEL_APPLY_FAILED);
} }
return $applyId; return $applyId;
} catch (Exception $e) { } catch (Exception $e) {
throw new MarketingException(MarketingException::COLONEL_APPLY_FAILED); throw new MarketingException($e->getMessage());
} }
} }
...@@ -124,9 +125,14 @@ class ColonelService ...@@ -124,9 +125,14 @@ class ColonelService
} }
$userIds = array_column($result['result'], 'user_id'); $userIds = array_column($result['result'], 'user_id');
$userMap = self::getUserMap($userIds); $userMap = self::getUserMap($userIds);
$takePlaceMap = self::getTakePlaceMap(array_column($result['result'], 'take_place_id'));
$incomeMap = PindanActivityInviteOrderService::incomeStatistics(["user_ids" => $userIds]); $incomeMap = PindanActivityInviteOrderService::incomeStatistics(["user_ids" => $userIds]);
foreach ($result['result'] as &$colonelVal) { foreach ($result['result'] as &$colonelVal) {
$userId = $colonelVal['user_id']; $userId = $colonelVal['user_id'];
$takePlaceInfo = !empty($takePlaceMap[$colonelVal['take_place_id']]) ? $takePlaceMap[$colonelVal['take_place_id']] : [];
$colonelVal['take_place_name'] = $takePlaceInfo['take_place_name'] ?? '';
$colonelVal['location'] = $takePlaceInfo['location'] ?? '';
$colonelVal['address'] = $takePlaceInfo['address'] ?? '';
$colonelVal['user_avatar'] = !empty($userMap[$userId]['user_avatar']) ? $userMap[$userId]['user_avatar'] : ''; $colonelVal['user_avatar'] = !empty($userMap[$userId]['user_avatar']) ? $userMap[$userId]['user_avatar'] : '';
$colonelVal['no_settlement_income'] = !empty($incomeMap[$userId]['no_settlement']) ? $incomeMap[$userId]['no_settlement'] : 0; $colonelVal['no_settlement_income'] = !empty($incomeMap[$userId]['no_settlement']) ? $incomeMap[$userId]['no_settlement'] : 0;
$colonelVal['total_income'] = !empty($incomeMap[$userId]['all_reward']) ? $incomeMap[$userId]['all_reward'] : 0; $colonelVal['total_income'] = !empty($incomeMap[$userId]['all_reward']) ? $incomeMap[$userId]['all_reward'] : 0;
...@@ -159,25 +165,28 @@ class ColonelService ...@@ -159,25 +165,28 @@ class ColonelService
try { try {
ColonelDistributorColonelApply::beginTransaction(); ColonelDistributorColonelApply::beginTransaction();
// 修改申请状态 // 修改申请状态
$updateStatus = ColonelDistributorColonelApply::updateRecord(['audit_status' => $auditStatus], $updateStatus = ColonelDistributorColonelApply::updateRecord([
['colonel_apply_id' => $applyId, 'audit_status' => ColonelDistributorColonelApply::STATUS_AUDIT] 'audit_status' => $auditStatus,
'update_time' => date('Y-m-d H:i:s')
],
['colonel_apply_id' => $applyId, 'audit_status[!]' => ColonelDistributorColonelApply::STATUS_PASS]
); );
if (empty($updateStatus)) { if (empty($updateStatus)) {
throw new MarketingException(MarketingException::COLONEL_AUDIT_STATUS_FAILED); throw new Exception(MarketingException::COLONEL_AUDIT_STATUS_FAILED);
} }
// 审核成功 // 审核成功
if ($auditStatus == ColonelDistributorColonelApply::STATUS_PASS) { if ($auditStatus == ColonelDistributorColonelApply::STATUS_PASS) {
if (!self::handleAuditSuccess((array)$applyInfo)) { if (!self::handleAuditSuccess((array)$applyInfo)) {
throw new MarketingException(MarketingException::COLONEL_ADD_FAILED); throw new Exception(MarketingException::COLONEL_ADD_FAILED);
} }
} }
if (!ColonelDistributorColonelApply::commit()) { if (!ColonelDistributorColonelApply::commit()) {
throw new MarketingException(MarketingException::COMMIT_ERROR); throw new Exception(MarketingException::COMMIT_ERROR);
} }
return true; return true;
} catch (MarketingException $e) { } catch (Exception $e) {
ColonelDistributorColonelApply::rollback(); ColonelDistributorColonelApply::rollback();
throw new MarketingException($e->getCode()); throw new MarketingException($e->getMessage());
} }
} }
...@@ -224,19 +233,19 @@ class ColonelService ...@@ -224,19 +233,19 @@ class ColonelService
ColonelDistributorColonel::beginTransaction(); ColonelDistributorColonel::beginTransaction();
// 添加自提点 // 添加自提点
if (!$takePlaceId = TakePlaceService::add($params)) { if (!$takePlaceId = TakePlaceService::add($params)) {
throw new MarketingException(MarketingException::COLONEL_TAKE_PLACE_FAILED); throw new Exception(MarketingException::COLONEL_TAKE_PLACE_FAILED);
} }
// 修改自提点id // 修改自提点id
if (!ColonelDistributorColonel::updateRecord(['take_place_id' => $takePlaceId], $where)) { if (!ColonelDistributorColonel::updateRecord(['take_place_id' => $takePlaceId], $where)) {
throw new MarketingException(MarketingException::COLONEL_TAKE_PLACE_EDIT_FAILED); throw new Exception(MarketingException::COLONEL_TAKE_PLACE_EDIT_FAILED);
} }
if (!ColonelDistributorColonel::commit()) { if (!ColonelDistributorColonel::commit()) {
throw new MarketingException(MarketingException::COMMIT_ERROR); throw new Exception(MarketingException::COMMIT_ERROR);
} }
return (int)$takePlaceId; return (int)$takePlaceId;
} catch (MarketingException $e) { } catch (Exception $e) {
ColonelDistributorColonel::rollback(); ColonelDistributorColonel::rollback();
throw new MarketingException($e->getCode()); throw new MarketingException($e->getMessage());
} }
} }
...@@ -302,4 +311,34 @@ class ColonelService ...@@ -302,4 +311,34 @@ class ColonelService
$params['page_size'] = !empty($params['page_size']) ? $params['page_size'] : 20; $params['page_size'] = !empty($params['page_size']) ? $params['page_size'] : 20;
return $params; return $params;
} }
/**
* Notes: 获取自提点信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/8 6:16 下午
* @param array $takePlaceId
* @return array
*/
private static function getTakePlaceMap(array $takePlaceId): array
{
$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;
}
} }
...@@ -172,7 +172,9 @@ class MarketingService ...@@ -172,7 +172,9 @@ class MarketingService
foreach ($lists as &$val) { foreach ($lists as &$val) {
if($capitalPoolList[$val['capital_pool_id']]) { if($capitalPoolList[$val['capital_pool_id']]) {
$val['capital_pool'] = $capitalPoolList[$val['capital_pool_id']]; $val['capital_pool'] = $capitalPoolList[$val['capital_pool_id']];
foreach (['capital_pool_total','capital_pool_lock','capital_pool_used'] as $key){
$val['capital_pool'][$key] = sprintf("%0.02f",$val['capital_pool'][$key]/100);
}
$poolTotal += $val['capital_pool']['capital_pool_total']; $poolTotal += $val['capital_pool']['capital_pool_total'];
$poolUsed += $val['capital_pool']['capital_pool_used']; $poolUsed += $val['capital_pool']['capital_pool_used'];
$poolLock += $val['capital_pool']['capital_pool_lock']; $poolLock += $val['capital_pool']['capital_pool_lock'];
...@@ -1094,6 +1096,7 @@ class MarketingService ...@@ -1094,6 +1096,7 @@ class MarketingService
$marketingData["life_account_name"] = $marketingData["life_account_icon"] = ""; $marketingData["life_account_name"] = $marketingData["life_account_icon"] = "";
if (!empty($lifeAccountList[$pindanMarketing["publish_life_account_id"]])) { if (!empty($lifeAccountList[$pindanMarketing["publish_life_account_id"]])) {
$marketingData["life_account_admin_id"] = strval($lifeAccountList[$pindanMarketing["publish_life_account_id"]]["life_account_admin_id"]);//客户端需要字符串格式
$marketingData["life_account_name"] = $lifeAccountList[$pindanMarketing["publish_life_account_id"]]["life_account_name"]; $marketingData["life_account_name"] = $lifeAccountList[$pindanMarketing["publish_life_account_id"]]["life_account_name"];
$marketingData["life_account_icon"] = $lifeAccountList[$pindanMarketing["publish_life_account_id"]]["life_account_icon"]; $marketingData["life_account_icon"] = $lifeAccountList[$pindanMarketing["publish_life_account_id"]]["life_account_icon"];
$marketingData["life_account_register_days"] = self::countAccountRegisterDays($lifeAccountList[$pindanMarketing["publish_life_account_id"]]['create_time']); $marketingData["life_account_register_days"] = self::countAccountRegisterDays($lifeAccountList[$pindanMarketing["publish_life_account_id"]]['create_time']);
......
...@@ -23,9 +23,11 @@ class PindanActivityColonelConfigService ...@@ -23,9 +23,11 @@ class PindanActivityColonelConfigService
{ {
$date = $params["date"]; $date = $params["date"];
$today = date("Y-m-d"); $today = date("Y-m-d");
if ($date <= $today) { $hour = date("H");
if ($date < $today || ($date == $today && $hour >= 12)) {
throw new MarketingException(['cus' => MarketingException::COLONEL_DATE_ERROR]); throw new MarketingException(['cus' => MarketingException::COLONEL_DATE_ERROR]);
} }
$type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"]; $type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"];
$configList = $params["config"]; $configList = $params["config"];
$marketingId = $params["marketing_id"]; $marketingId = $params["marketing_id"];
......
...@@ -35,9 +35,10 @@ class PindanActivityInviteOrderService ...@@ -35,9 +35,10 @@ class PindanActivityInviteOrderService
return true; return true;
} }
$timeRange = PindanActivityColonelConfigService::getActivityTimeRange();
$inviteOrderNumData = [ $inviteOrderNumData = [
"colonel_user_id" => $params["colonel_user_id"], "colonel_user_id" => $params["colonel_user_id"],
"date" => date("Y-m-d") "date" => $timeRange['date']
]; ];
$inviteOrderNum = ColonelDistributorInviteOrderNum::selectMaster("*", $inviteOrderNumData, []); $inviteOrderNum = ColonelDistributorInviteOrderNum::selectMaster("*", $inviteOrderNumData, []);
...@@ -142,7 +143,7 @@ class PindanActivityInviteOrderService ...@@ -142,7 +143,7 @@ class PindanActivityInviteOrderService
$timeRange = self::getNoSettlementTimeRange(); $timeRange = self::getNoSettlementTimeRange();
$inviteOrderNumList = ColonelDistributorInviteOrderNum::select(["colonel_user_id", "num", "date"], [ $inviteOrderNumList = ColonelDistributorInviteOrderNum::select(["colonel_user_id", "num", "date"], [
"create_time[>]" => $timeRange["start_time"], "create_time[>]" => $timeRange["start_time"],
"create_time[<]" => $timeRange["end_time"], "colonel_user_id" => $userIds,
], []); ], []);
$inviteOrderNumData = []; $inviteOrderNumData = [];
$inviteOrderStatistics = []; $inviteOrderStatistics = [];
...@@ -212,7 +213,8 @@ class PindanActivityInviteOrderService ...@@ -212,7 +213,8 @@ class PindanActivityInviteOrderService
} else { } else {
$startTime = date('Y-m-d', strtotime('-2 day')).$hour; $startTime = date('Y-m-d', strtotime('-2 day')).$hour;
} }
$endTime = date("Y-m-d").$hour; //$endTime = date("Y-m-d").$hour;
$endTime = date("Y-m-d H:i:s"); // 结束时间应该取当前时间
return [ return [
'start_time' => $startTime, 'start_time' => $startTime,
...@@ -269,14 +271,18 @@ class PindanActivityInviteOrderService ...@@ -269,14 +271,18 @@ class PindanActivityInviteOrderService
} }
/** /**
* 团长分销,昨日转化单数,总转化单数 * 团长分销,累计转化单数
* @param array $params * @param array $params
* @return array * @return array
*/ */
public static function inviteOrderNumberStatistics($params = []) public static function inviteOrderNumberStatistics($params = [])
{ {
$timeRange = self::getNoSettlementTimeRange();
$userIds = $params["user_ids"]; $userIds = $params["user_ids"];
$allNums = ColonelDistributorInviteOrderNum::select(["colonel_user_id", "num"], ["colonel_user_id" => $userIds], []); $allNums = ColonelDistributorInviteOrderNum::select(
["colonel_user_id", "num"],
["colonel_user_id" => $userIds, "create_time[<]" => $timeRange["start_time"]], []);
$allData = array_column($allNums, null, "colonel_user_id"); $allData = array_column($allNums, null, "colonel_user_id");
$data = []; $data = [];
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Services\tcc; namespace App\Services\tcc;
use Api\PhpUtils\Common\GoodsSkuId; use Api\PhpUtils\Common\GoodsSkuId;
use Api\PhpUtils\Log\FileLog;
use App\Exception\custom\GoodsException; use App\Exception\custom\GoodsException;
use App\Models\goods\mysql\GoodsSku; use App\Models\goods\mysql\GoodsSku;
use App\Models\goods\mysql\PindanGoodsSku; use App\Models\goods\mysql\PindanGoodsSku;
...@@ -491,7 +492,7 @@ class Tcc2Service ...@@ -491,7 +492,7 @@ class Tcc2Service
} }
} }
} }
FileLog::info('goods_cancel_confirm_tcc', 'json decode error raw:' . $keys);
if ($isPindan) { if ($isPindan) {
return self::pindanCancelConfirm($goodsInfoList); return self::pindanCancelConfirm($goodsInfoList);
} else { } else {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"php": "7.2.*", "php": "7.2.*",
"ext-json": "*", "ext-json": "*",
"api/php_utils":"1.0.17", "api/php_utils":"1.0.17",
"api/php_services":"1.0.13", "api/php_services":"1.0.14",
"ext-openssl": "*" "ext-openssl": "*"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
......
This diff is collapsed.
type=command type=command
command=bash docker run --rm -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-10-image /bin/bash -c "cd /home/services && sh start_job.sh test ColonelOrder index a=3&b=4" command=docker run --rm -e YIDIAN_LOCAL_IP=10.138.0.27 -e YIDIAN_LOCAL_PORT= -e ORIGIN_SERVICE_PORT= -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-107-image /bin/bash -c "sysctl -w net.core.somaxconn=65535 && cd /home/services && sh start_job.sh test Colonelorder index a=3"
\ No newline at end of file \ No newline at end of file
type=command type=command
command=bash docker run --rm -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-10-image /bin/bash -c "cd /home/services && sh start_job.sh test ColonelWallet index a=3&b=4" command=docker run --rm -e YIDIAN_LOCAL_IP=10.138.0.27 -e YIDIAN_LOCAL_PORT= -e ORIGIN_SERVICE_PORT= -e LANG=en_US.UTF-8 -e TZ=Asia/Shanghai --net=bridge -h "`hostname`" --cap-add SYS_PTRACE --privileged docker2.yidian.com:5000/publish/bp-goods-azkaban-test-107-image /bin/bash -c "sysctl -w net.core.somaxconn=65535 && cd /home/services && sh start_job.sh test Colonelwallet index a=3"
dependencies=run-colonel-order dependencies=run-colonel-order
\ No newline at end of file
...@@ -37,8 +37,17 @@ class JwUser ...@@ -37,8 +37,17 @@ class JwUser
} }
$params = ["mobilePhone" => $params['mobile']]; $params = ["mobilePhone" => $params['mobile']];
//$user_info = (new TimeOut())->runGet($url, $params); $begin = microtime(true);
$user_info = (new Request())->get($url, $params); $user_info = (new Request())->get($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
$code = $user_info['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_getUserInfo', json_encode($user_info)); FileLog::info('jw_user_getUserInfo', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -61,7 +70,6 @@ class JwUser ...@@ -61,7 +70,6 @@ class JwUser
} }
$params = ["userId" => $params['user_id']]; $params = ["userId" => $params['user_id']];
//$user_info = (new TimeOut())->runPost($url, $params);
$begin = microtime(true); $begin = microtime(true);
$user_info = (new Request())->post($url, $params); $user_info = (new Request())->post($url, $params);
$end = microtime(true); $end = microtime(true);
...@@ -71,7 +79,9 @@ class JwUser ...@@ -71,7 +79,9 @@ class JwUser
} else { } else {
$code = -1; $code = -1;
} }
MonUtil::proxyMon($url, $code, 'jw_user', $total_time);
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_getUserByUserId', json_encode($user_info)); FileLog::info('jw_user_getUserByUserId', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -91,8 +101,17 @@ class JwUser ...@@ -91,8 +101,17 @@ class JwUser
} }
$params = ["userIds" => $params['user_id']]; $params = ["userIds" => $params['user_id']];
//$user_info = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$user_info = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $user_info = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
$code = $user_info['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_getUserList', json_encode($user_info)); FileLog::info('jw_user_getUserList', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -139,7 +158,17 @@ class JwUser ...@@ -139,7 +158,17 @@ class JwUser
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
//$pushToken = (new TimeOut())->runPost($url, $params); //$pushToken = (new TimeOut())->runPost($url, $params);
$pushToken = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $begin = microtime(true);
$pushToken = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($pushToken['response'])) {
$code = $pushToken['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_savePushToken', json_encode($pushToken)); FileLog::info('jw_user_savePushToken', json_encode($pushToken));
if (!$pushToken) { if (!$pushToken) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -163,8 +192,17 @@ class JwUser ...@@ -163,8 +192,17 @@ class JwUser
} }
$params = ["userIds" => $params['user_id']]; $params = ["userIds" => $params['user_id']];
//$list = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$list = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $list = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($list['response'])) {
$code = $list['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_getUserListWithDynamic', json_encode($list)); FileLog::info('jw_user_getUserListWithDynamic', json_encode($list));
if (!$list) { if (!$list) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -188,8 +226,17 @@ class JwUser ...@@ -188,8 +226,17 @@ class JwUser
} }
$params = ["userId" => $params['user_id']]; $params = ["userId" => $params['user_id']];
//$list = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$list = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $list = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($list['response'])) {
$code = $list['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_getUserDigg', json_encode($list)); FileLog::info('jw_user_getUserDigg', json_encode($list));
if (!$list) { if (!$list) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -206,8 +253,17 @@ class JwUser ...@@ -206,8 +253,17 @@ class JwUser
if (!$url) { if (!$url) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
//$ret = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$ret = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $ret = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($ret['response'])) {
$code = $ret['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('jw_user_saveUpdateLife', json_encode($ret)); FileLog::info('jw_user_saveUpdateLife', json_encode($ret));
if (!$ret) { if (!$ret) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -224,8 +280,17 @@ class JwUser ...@@ -224,8 +280,17 @@ class JwUser
if (!$url) { if (!$url) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
//$ret = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$ret = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $ret = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($ret['response'])) {
$code = $ret['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('getWechatOpenid', json_encode($ret)); FileLog::info('getWechatOpenid', json_encode($ret));
if (!$ret) { if (!$ret) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
...@@ -243,8 +308,17 @@ class JwUser ...@@ -243,8 +308,17 @@ class JwUser
if (!$url) { if (!$url) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
//$ret = (new TimeOut())->runPost($url, $params); $begin = microtime(true);
$ret = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user'); $ret = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($ret['response'])) {
$code = $ret['response']['code'];
} else {
$code = -1;
}
$env = \Yaf\Application::app()->environ() ?? "test";
MonUtil::proxyMon($url, $code, 'jw_user_'.$env, $total_time);
FileLog::info('getWechatOpenid', json_encode($ret)); FileLog::info('getWechatOpenid', json_encode($ret));
if (!$ret) { if (!$ret) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
......
...@@ -338,7 +338,7 @@ class ClassLoader ...@@ -338,7 +338,7 @@ class ClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
* @return true|null True if loaded, null otherwise * @return bool|null True if loaded, null otherwise
*/ */
public function loadClass($class) public function loadClass($class)
{ {
...@@ -347,8 +347,6 @@ class ClassLoader ...@@ -347,8 +347,6 @@ class ClassLoader
return true; return true;
} }
return null;
} }
/** /**
......
This diff is collapsed.
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
"packages": [ "packages": [
{ {
"name": "api/php_services", "name": "api/php_services",
"version": "v1.0.13", "version": "1.0.14",
"version_normalized": "1.0.13.0", "version_normalized": "1.0.14.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git", "url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "c51c248e6e7aba33fd147993b5f61f140ccd56ca" "reference": "f2ba54cfaff45ffa8c0c4864f3b4935e1fcb3cfa"
}, },
"require": { "require": {
"endroid/qr-code": "^3.9", "endroid/qr-code": "^3.9",
"perftools/php-profiler": "^0.18.0", "perftools/php-profiler": "^0.18.0",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-09-02T06:50:55+00:00", "time": "2021-09-08T06:38:07+00:00",
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
"autoload": { "autoload": {
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ CHANGELOG ...@@ -10,7 +10,7 @@ CHANGELOG
5.2.0 5.2.0
----- -----
* deprecated the `enable_magic_call_extraction` context option in `ReflectionExtractor::getWriteInfo()` and `ReflectionExtractor::getReadInfo()`. in favor of `enable_magic_methods_extraction` * deprecated the `enable_magic_call_extraction` context option in `ReflectionExtractor::getWriteInfo()` and `ReflectionExtractor::getReadInfo()` in favor of `enable_magic_methods_extraction`
5.1.0 5.1.0
----- -----
......
...@@ -552,8 +552,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp ...@@ -552,8 +552,8 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
$types = []; $types = [];
$nullable = $reflectionType->allowsNull(); $nullable = $reflectionType->allowsNull();
foreach ($reflectionType instanceof \ReflectionUnionType ? $reflectionType->getTypes() : [$reflectionType] as $type) { foreach (($reflectionType instanceof \ReflectionUnionType || $reflectionType instanceof \ReflectionIntersectionType) ? $reflectionType->getTypes() : [$reflectionType] as $type) {
$phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string) $type; $phpTypeOrClass = $type->getName();
if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass || 'never' === $phpTypeOrClass) { if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass || 'never' === $phpTypeOrClass) {
continue; continue;
} }
......
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