Commit 75f2b639 authored by luhongguang's avatar luhongguang

Merge branch 'colonel' of https://git.yidian-inc.com:8021/bp/goods into colonel

parents 9603d7ba e668cd25
...@@ -22,5 +22,8 @@ class UserException extends BaseException ...@@ -22,5 +22,8 @@ class UserException extends BaseException
8 => '绑定手机号失败', 8 => '绑定手机号失败',
9 => '该手机号已绑定其他用户不能重复绑定', 9 => '该手机号已绑定其他用户不能重复绑定',
10 => 'mysql 异常', 10 => 'mysql 异常',
11 => '头像昵称更新失败',
12 => '绑定手机号保存失败',
13 => '请求太频繁,稍后重试',
]; ];
} }
\ No newline at end of file
...@@ -15,11 +15,6 @@ class ColonelConfigValidate extends BaseValidate ...@@ -15,11 +15,6 @@ class ColonelConfigValidate extends BaseValidate
'marketing_id' => 'marketing_id 参数不能为空', 'marketing_id' => 'marketing_id 参数不能为空',
]; ];
public function sceneDate()
{
return $this->only(["date"])->append("date", "require");
}
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(["date","config","marketing_id"])->append("marketing_id", "require"); return $this->only(["date","config","marketing_id"])->append("marketing_id", "require");
......
...@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase ...@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase
return self::get($columns, $where); return self::get($columns, $where);
} }
public static function getRecordMaster($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::getMaster($columns, $where);
}
public static function getRecords($where, $columns = []) public static function getRecords($where, $columns = [])
{ {
if (empty($columns)) { if (empty($columns)) {
...@@ -34,7 +42,7 @@ class UserWechatBind extends MysqlBase ...@@ -34,7 +42,7 @@ class UserWechatBind extends MysqlBase
return self::select($columns, $where); return self::select($columns, $where);
} }
public static function getRecordMaster($where, $columns = []) public static function getRecordsMaster ($where, $columns = [])
{ {
if (empty($columns)) { if (empty($columns)) {
$columns = '*'; $columns = '*';
......
...@@ -101,7 +101,7 @@ class ColonelorderController extends Job ...@@ -101,7 +101,7 @@ class ColonelorderController extends Job
*/ */
private function getInviteNewUserData($userIds, &$colonelPayInfoData) private function getInviteNewUserData($userIds, &$colonelPayInfoData)
{ {
if ($inviteNewUserList = $this->getInviteNewUserList($userIds)) { if ($inviteNewUserList = $this->getInviteNewUserList($userIds,$this->startTime,$this->endTime)) {
$userNickList = $this->getUserList(array_column($inviteNewUserList, 'user_id')); $userNickList = $this->getUserList(array_column($inviteNewUserList, 'user_id'));
foreach ($inviteNewUserList as $newUser) { foreach ($inviteNewUserList as $newUser) {
$colonelPayInfoData[] = [ $colonelPayInfoData[] = [
...@@ -148,24 +148,19 @@ class ColonelorderController extends Job ...@@ -148,24 +148,19 @@ class ColonelorderController extends Job
/** /**
* 团长任务配置 * 团长任务配置
* @param $yesterday * @param $settlementDate
* @return array * @return array
*/ */
private function getColonelConfig($yesterday): array private function getColonelConfig($settlementDate): array
{ {
$config = ColonelDistributorConfig::getRecord([ $config = ColonelDistributorConfig::getRecord([
'date' => $yesterday, 'date[<=]' => $settlementDate,
'type' => ColonelDistributorConfig::TYPE_COLONEL 'type' => ColonelDistributorConfig::TYPE_COLONEL,
]);
if (empty($config)) {
$config = ColonelDistributorConfig::getRecord([
'date[<=]' => $yesterday,
'ORDER' => ['date' => 'DESC'], 'ORDER' => ['date' => 'DESC'],
'LIMIT' => 1 'LIMIT' => 1
]); ]);
}
$configData = []; $configData = [];
if (empty($config['data'])) { if (!empty($config['data'])) {
$configData = json_decode($config['data'], true); $configData = json_decode($config['data'], true);
} }
return $configData; return $configData;
...@@ -193,10 +188,12 @@ class ColonelorderController extends Job ...@@ -193,10 +188,12 @@ class ColonelorderController extends Job
* User: pengfei@yidian-inc.com * User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:03 下午 * Date: 2021/9/3 4:03 下午
* @param $userIds * @param $userIds
* @param $startTime
* @param $endTime
* @return array * @return array
* @throws InterfaceException * @throws InterfaceException
*/ */
private function getInviteNewUserList($userIds): array private function getInviteNewUserList($userIds,$startTime,$endTime): array
{ {
$url = config('interface', 'coupon.background.wx_invite_relation_list_by_user_ids'); $url = config('interface', 'coupon.background.wx_invite_relation_list_by_user_ids');
if (empty($url)) { if (empty($url)) {
...@@ -204,7 +201,7 @@ class ColonelorderController extends Job ...@@ -204,7 +201,7 @@ class ColonelorderController extends Job
} }
$res = HttpUtil::get($url, $res = HttpUtil::get($url,
['user_ids' => $userIds, 'start_time' => $this->startTime, 'end_time' => $this->endTime]); ['user_ids' => $userIds, 'start_time' => $startTime, 'end_time' => $endTime]);
if (!empty($res['response']['result'])) { if (!empty($res['response']['result'])) {
return array_values(array_column($res['response']['result'], null, 'user_id')); return array_values(array_column($res['response']['result'], null, 'user_id'));
} }
......
...@@ -34,6 +34,8 @@ class ColonelwalletController extends Job ...@@ -34,6 +34,8 @@ class ColonelwalletController extends Job
if ($this->toWallet($payInfoList)) { if ($this->toWallet($payInfoList)) {
if ($this->handlePayInfoStatus(array_column($payInfoList, 'pay_info_id'))) { if ($this->handlePayInfoStatus(array_column($payInfoList, 'pay_info_id'))) {
$this->loggerInfo('success'); $this->loggerInfo('success');
} else {
$this->loggerInfo('更新状态失败');
} }
} }
} }
......
...@@ -68,8 +68,6 @@ class ColonelController extends Base ...@@ -68,8 +68,6 @@ class ColonelController extends Base
*/ */
public function colonel_configAction() public function colonel_configAction()
{ {
(new ColonelConfigValidate())->scene("date")->validate();
$params = $this->params; $params = $this->params;
$data = PindanActivityColonelConfigService::colonelConfig($params); $data = PindanActivityColonelConfigService::colonelConfig($params);
return $this->success(["result" => $data]); return $this->success(["result" => $data]);
......
...@@ -157,11 +157,6 @@ class GoodsService ...@@ -157,11 +157,6 @@ class GoodsService
throw new GoodsException(['cus' => 2]); throw new GoodsException(['cus' => 2]);
} }
$spuId = $res[0]; $spuId = $res[0];
$checkName = self::checkGoodsName($spuData["goods_name"], $spuData["life_account_id"]);
if (!$checkName["can_use"]) {
throw new GoodsException(['cus' => 17]);
}
$spuParams = [ $spuParams = [
"goods_spu_id" => $spuId, "goods_spu_id" => $spuId,
"shop_id" => $shopId, "shop_id" => $shopId,
...@@ -771,13 +766,6 @@ class GoodsService ...@@ -771,13 +766,6 @@ class GoodsService
*/ */
private static function editGoodsSpu($goodsSpu, $params = []) private static function editGoodsSpu($goodsSpu, $params = [])
{ {
$checkName = self::checkGoodsName($params["goods_name"], $goodsSpu["life_account_id"], $goodsSpu["goods_spu_id"]);
if (!$checkName["can_use"]) {
throw new GoodsException(['cus' => 17]);
}
return GoodsSpu::save([ return GoodsSpu::save([
"goods_name" => $params["goods_name"], "goods_name" => $params["goods_name"],
"desc_pic_url" => $params["desc_pic_url"], "desc_pic_url" => $params["desc_pic_url"],
......
...@@ -165,12 +165,6 @@ class MarketingPindanGoodsService ...@@ -165,12 +165,6 @@ class MarketingPindanGoodsService
*/ */
private static function addGoodsSku($spuData, $shopId, $skuData = []) private static function addGoodsSku($spuData, $shopId, $skuData = [])
{ {
$pindanSku = PindanGoodsSku::get("goods_sku_id", ["goods_name" => $skuData["goods_name"]
, "life_account_id" => $skuData["life_account_id"]]);
if (!empty($pindanSku)) {
throw new GoodsException(['cus' => 17]);
}
$res = GoodsService::getIdgenId(substr($shopId, -2), "goods"); $res = GoodsService::getIdgenId(substr($shopId, -2), "goods");
if (empty($res)) { if (empty($res)) {
throw new GoodsException(['cus' => 2]); throw new GoodsException(['cus' => 2]);
...@@ -267,11 +261,6 @@ class MarketingPindanGoodsService ...@@ -267,11 +261,6 @@ class MarketingPindanGoodsService
*/ */
private static function editGoodsSpu($goodsSpu, $params = []) private static function editGoodsSpu($goodsSpu, $params = [])
{ {
$checkName = GoodsService::checkGoodsName($params["goods_name"], $goodsSpu["life_account_id"], $goodsSpu["goods_spu_id"]);
if (!$checkName["can_use"]) {
throw new GoodsException(['cus' => 17]);
}
return GoodsSpu::save([ return GoodsSpu::save([
"desc_pic_url" => $params["desc_pic_url"], "desc_pic_url" => $params["desc_pic_url"],
"desc" => $params["desc"], "desc" => $params["desc"],
......
...@@ -65,9 +65,16 @@ class PindanActivityColonelConfigService ...@@ -65,9 +65,16 @@ class PindanActivityColonelConfigService
*/ */
public static function colonelConfig($params = []) public static function colonelConfig($params = [])
{ {
$day = empty($params["date"]) ? date("Y-m-d") : $params["date"]; $day = $params["date"];
$type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"]; $type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"];
if(empty($day)) {
//默认取最近更新的一条配置
$config = ColonelDistributorConfig::getRecord([
"type" => $type,"ORDER" => ["update_time" => "DESC"], "LIMIT" => 1
]);
}else {
$config = ColonelDistributorConfig::getRecord(["date" => $day, "type" => $type]); $config = ColonelDistributorConfig::getRecord(["date" => $day, "type" => $type]);
}
if (empty($config)) { if (empty($config)) {
$config = ColonelDistributorConfig::getRecord([ $config = ColonelDistributorConfig::getRecord([
"date[<=]" => $day, "date[<=]" => $day,
......
...@@ -14,6 +14,8 @@ use Api\PhpServices\Idgen\Idgen; ...@@ -14,6 +14,8 @@ use Api\PhpServices\Idgen\Idgen;
use Api\PhpUtils\Redis\RedisUtil; use Api\PhpUtils\Redis\RedisUtil;
use Api\PhpServices\JwUser\JwUser; use Api\PhpServices\JwUser\JwUser;
use App\Services\common\CommonService; use App\Services\common\CommonService;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Lock\FrequencyLockUtil;
class UserService class UserService
{ {
...@@ -23,13 +25,14 @@ class UserService ...@@ -23,13 +25,14 @@ class UserService
public static function wechatLogin($params) public static function wechatLogin($params)
{ {
$code = !empty($params['code']) ? $params['code'] : '';//小程序授权code $code = !empty($params['code']) ? $params['code'] : '';//小程序授权code
$openid = !empty($params['openid']) ? $params['openid'] : '';//小程序授权code $openid = !empty($params['openid']) ? $params['openid'] : '';//小程序授权code
if (empty($code) && empty($openid)) { if (empty($code) && empty($openid)) {
FileLog::error("wechatLogin:获取参数为空", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 0]); throw new UserException(['cus' => 0]);
} }
//需要授权微信 //需要授权微信
//if (empty($openid)) { //if (empty($openid)) {
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
...@@ -51,6 +54,7 @@ class UserService ...@@ -51,6 +54,7 @@ class UserService
if (empty($response) || array_key_exists('errcode', $response)) { if (empty($response) || array_key_exists('errcode', $response)) {
//throw new \Exception('获取openid失败:' . $response['errcode']); //throw new \Exception('获取openid失败:' . $response['errcode']);
FileLog::error("wechatLogin:获取openid失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 1]); throw new UserException(['cus' => 1]);
} }
//检查系统是已注册 //检查系统是已注册
...@@ -58,7 +62,7 @@ class UserService ...@@ -58,7 +62,7 @@ class UserService
//} //}
$user = UserWechatBind::getRecord(['openid' => $openid]); $user = UserWechatBind::getRecordMaster(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户 //如果系统不存在,用户信息,则注册新用户
if (empty($user) && !empty($response)) { if (empty($user) && !empty($response)) {
$insert = [ $insert = [
...@@ -68,8 +72,13 @@ class UserService ...@@ -68,8 +72,13 @@ class UserService
'create_time' => date("Y-m-d H:i:s") 'create_time' => date("Y-m-d H:i:s")
]; ];
$newWechatId = UserWechatBind::save($insert); $sessionKey = !empty($response['session_key']) ? $response['session_key'] : '';
//$newWechatId = UserWechatBind::save($insert);
$newWechatId =UserWechatBind::insertDuplicate($insert, ['session_key' => $sessionKey,'create_time' => date("Y-m-d H:i:s")]);
if (!$newWechatId) { if (!$newWechatId) {
FileLog::error("wechatLogin:登陆创建用户失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("wechatLogin:登陆创建用户失败--insert", json_encode($insert, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 2]); throw new UserException(['cus' => 2]);
} }
...@@ -78,13 +87,17 @@ class UserService ...@@ -78,13 +87,17 @@ class UserService
$user['session_key'] = $response['session_key']; $user['session_key'] = $response['session_key'];
}else{ }else{
if (empty($user)) { if (empty($user)) {
FileLog::error("wechatLogin:登陆创建用户失败-- 微信response", json_encode($response, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 2]); throw new UserException(['cus' => 2]);
} }
if (empty($response)){
FileLog::error("wechatLogin:登陆创建用户失败-- 微信response 获取失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 2]);
}
$insert = [ $insert = [
'session_key' => !empty($response['session_key']) ? $response['session_key'] : '', 'session_key' => !empty($response['session_key']) ? $response['session_key'] : '',
]; ];
$newWechatId = UserWechatBind::save($insert,['openid' => $openid]); $newWechatId = UserWechatBind::save($insert,['openid' => $openid]);
} }
...@@ -108,17 +121,20 @@ class UserService ...@@ -108,17 +121,20 @@ class UserService
$appid = \Yaf\Registry::get('config')->wechat->appid; $appid = \Yaf\Registry::get('config')->wechat->appid;
if (!$encryptedData) { if (!$encryptedData) {
FileLog::error("bindPhone:encryptedData 为空", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 3]); throw new UserException(['cus' => 3]);
} }
if (!$iv) { if (!$iv) {
FileLog::error("bindPhone:iv 为空", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 4]); throw new UserException(['cus' => 4]);
} }
$userInfo = UserWechatBind::getRecord(['openid' => $openid]); $userInfo = UserWechatBind::getRecordMaster(['openid' => $openid]);
$sessionKey = !empty($userInfo['session_key']) ? $userInfo['session_key'] : ''; $sessionKey = !empty($userInfo['session_key']) ? $userInfo['session_key'] : '';
$openid = isset($userInfo['openid']) && $userInfo['openid'] ? $userInfo['openid'] : ''; $openid = isset($userInfo['openid']) && $userInfo['openid'] ? $userInfo['openid'] : '';
if (empty($userInfo) || !$sessionKey || !$openid) { if (empty($userInfo) || !$sessionKey || !$openid) {
FileLog::error("bindPhone:userInfo获取失败", json_encode($userInfo, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 5]); throw new UserException(['cus' => 5]);
} }
...@@ -128,18 +144,23 @@ class UserService ...@@ -128,18 +144,23 @@ class UserService
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData); $errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) { if ($errCode) {
FileLog::error("bindPhone:解密失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 6]); throw new UserException(['cus' => 6]);
} }
// 手机号解密成功 // 手机号解密失败
if (empty($decryptData['phoneNumber'])) { if (empty($decryptData['phoneNumber'])) {
FileLog::error("bindPhone:手机号解密失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("bindPhone:手机号解密失败--decryptData", json_encode($decryptData, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 7]); throw new UserException(['cus' => 7]);
} }
$phoneNumber = strval($decryptData['phoneNumber']); $phoneNumber = strval($decryptData['phoneNumber']);
//判断是否已 //判断是否已
$user = UserWechatBind::getRecord(['phone' => $phoneNumber]); $user = UserWechatBind::getRecordMaster(['phone' => $phoneNumber]);
if (!empty($user) && $openid != $user['openid']) { if (!empty($user) && $openid != $user['openid']) {
FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定--user", json_encode($user, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 9]); throw new UserException(['cus' => 9]);
} }
...@@ -157,7 +178,13 @@ class UserService ...@@ -157,7 +178,13 @@ class UserService
]; ];
$bindStatus = UserWechatBind::save($update,['wechat_id' => $userInfo['wechat_id']]); $bindStatus = UserWechatBind::save($update,['wechat_id' => $userInfo['wechat_id']]);
if (empty($bindStatus)){
FileLog::error("bindPhone:绑定手机号保存失败", json_encode($update, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 12]);
}
if (!$phoneNumber) { if (!$phoneNumber) {
FileLog::error("bindPhone:该手机号已绑定其他用户不能重复绑定--user", json_encode($user, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 8]); throw new UserException(['cus' => 8]);
} }
...@@ -210,10 +237,17 @@ class UserService ...@@ -210,10 +237,17 @@ class UserService
"city" => !empty($params['city']) ? $params['city'] : '', "city" => !empty($params['city']) ? $params['city'] : '',
"language" => !empty($params['language']) ? $params['language'] : '', "language" => !empty($params['language']) ? $params['language'] : '',
]; ];
$user = UserWechatBind::getRecordMaster(['openid' => $params['openid']]);
if (empty($user)){
$update['openid'] = $params['openid'];
$bindStatus = UserWechatBind::save($update);
}else{
$bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]); $bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]);
}
if (!$bindStatus) { if (!$bindStatus) {
throw new UserException(['cus' => 8]); FileLog::error("bindAvatar:绑定头像失败", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("bindAvatar:绑定头像失败--update", json_encode($update, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
throw new UserException(['cus' => 11]);
} }
return $update; return $update;
} }
......
...@@ -31,6 +31,6 @@ exception.sys.msg = "系统未定义异常,研发正在赶来的路上..." ...@@ -31,6 +31,6 @@ exception.sys.msg = "系统未定义异常,研发正在赶来的路上..."
[prod : common : exception] [prod : common : exception]
[pre : common : exception] [perf : common : exception]
[test : common : exception] [test : common : exception]
[dev : common : exception] [dev : common : exception]
\ No newline at end of file
...@@ -11,6 +11,6 @@ idgen.partner = "bp" ...@@ -11,6 +11,6 @@ idgen.partner = "bp"
idgen.key = "5cfdb867e96374c7883b31d6928cc4cb" idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
[prod : common] [prod : common]
[pre : common ] [perf : common ]
[test: common ] [test: common ]
[dev : common ] [dev : common ]
\ No newline at end of file
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