Commit bc3e64b8 authored by suntengda's avatar suntengda

Merge branch 'master' into tuancan

parents 644155a2 824b111a
...@@ -70,5 +70,6 @@ class GoodsException extends BaseException ...@@ -70,5 +70,6 @@ class GoodsException extends BaseException
49 => '库存不得小于已售库存', 49 => '库存不得小于已售库存',
self::RULE_LIMIT_ERROR => '单人可买上限填写错误', self::RULE_LIMIT_ERROR => '单人可买上限填写错误',
self::NOT_FIND_MARKETING => '找不到活动', self::NOT_FIND_MARKETING => '找不到活动',
52 => '过期时间不得小于等于上架开始时间',
]; ];
} }
\ No newline at end of file
...@@ -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
<?php
namespace Validate;
/**
* Class GoodsAuditValidate
*
* @package Validate
*/
class GoodsOnlineSiteValidate extends BaseValidate
{
protected $rule = [
'goods_spu_id' => 'require',
'online_type' => 'require',
];
protected $message = [
"goods_spu_id" => "商品id不能为空",
"online_type" => "设置类型不能为空",
];
}
\ No newline at end of file
...@@ -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 = '*';
......
...@@ -16,6 +16,7 @@ use \Validate\GoodsOnlineOfflineValidate; ...@@ -16,6 +16,7 @@ use \Validate\GoodsOnlineOfflineValidate;
use \Validate\PaySuccessGoodsCallbackValidate; use \Validate\PaySuccessGoodsCallbackValidate;
use \Validate\GoodsInitShopValidate; use \Validate\GoodsInitShopValidate;
use \Validate\PindanGoodsAddValidate; use \Validate\PindanGoodsAddValidate;
use \Validate\GoodsOnlineSiteValidate;
use \App\Services\goods\ElasticGoodService; use \App\Services\goods\ElasticGoodService;
use \App\Services\goods\MarketingPindanGoodsService; use \App\Services\goods\MarketingPindanGoodsService;
use \App\Models\marketing\mysql\Marketing; use \App\Models\marketing\mysql\Marketing;
...@@ -118,6 +119,20 @@ class GoodsController extends Base ...@@ -118,6 +119,20 @@ class GoodsController extends Base
$this->success(); $this->success();
} }
/**
* 修改商品定点上架设置
* @date 2021-08-25
* @license [license]
* @version [version]
*/
public function online_siteAction()
{
$params = $this->params;
(new GoodsOnlineSiteValidate())->validate();
GoodsService::onlineSite($params);
$this->success();
}
/** /**
* 审核通过/驳回 * 审核通过/驳回
*/ */
......
This diff is collapsed.
...@@ -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"],
......
...@@ -150,12 +150,12 @@ class MarketingGoodsService ...@@ -150,12 +150,12 @@ class MarketingGoodsService
//比例 //比例
if (!empty($secondCommission) && $commissionMode == 1) { if (!empty($secondCommission) && $commissionMode == 1) {
$price = !empty($list[$i]['price']) ? $list[$i]['price'] : 0; $price = !empty($list[$i]['price']) ? $list[$i]['price'] : 0;
$list[$i]['share_price'] = substr(sprintf("%.4f",$secondCommission*$price/100),0,-2); $list[$i]['share_price'] = (float) substr(sprintf("%.4f",$secondCommission*$price/100),0,-2);
} }
//固定 //固定
if (!empty($commissionMode) && $commissionMode == 2) { if (!empty($commissionMode) && $commissionMode == 2) {
$list[$i]['share_price'] = substr(sprintf("%.4f",$secondCommission/100),0,-2); $list[$i]['share_price'] = (float) substr(sprintf("%.4f",$secondCommission),0,-2);
} }
$content = $userId .'_' .$value['marketing_id']; $content = $userId .'_' .$value['marketing_id'];
...@@ -195,9 +195,13 @@ class MarketingGoodsService ...@@ -195,9 +195,13 @@ class MarketingGoodsService
$data = []; $data = [];
foreach ($marketingInfoIds as $goodsSkuId => $marketingId) { foreach ($marketingInfoIds as $goodsSkuId => $marketingId) {
if (!empty($marketingList[$marketingId]["second_commission_value"])) { if (!empty($marketingList[$marketingId]["second_commission_value"]) && $marketingList[$marketingId]["commission_mode"] == 1) {
$data[$goodsSkuId] = substr(sprintf("%.4f", $marketingList[$marketingId]["second_commission_value"]/10000), 0, -2); $data[$goodsSkuId] = substr(sprintf("%.4f", $marketingList[$marketingId]["second_commission_value"]/10000), 0, -2);
} }
if (!empty($marketingList[$marketingId]["second_commission_value"]) && $marketingList[$marketingId]["commission_mode"] == 2) {
$data[$goodsSkuId] = substr(sprintf("%.4f", $marketingList[$marketingId]["second_commission_value"]/100), 0, -2);
}
} }
return $data; return $data;
} }
......
...@@ -518,6 +518,9 @@ class MarketingService ...@@ -518,6 +518,9 @@ class MarketingService
$clearPrice = !empty($value["clear_price"]) ? $value["clear_price"] : 0; $clearPrice = !empty($value["clear_price"]) ? $value["clear_price"] : 0;
$price = !empty($value["price"]) ? $value["price"] : 0; $price = !empty($value["price"]) ? $value["price"] : 0;
$chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分) $chargeFee = !empty($price) ? (float)bcmul($price , self::CHARGEFEE,2) : 0; //手续费 (分)
if ($chargeFee < 1) {
$chargeFee = 0;
}
if (!empty($clearPrice) && $clearPrice > 0) { if (!empty($clearPrice) && $clearPrice > 0) {
if ($commissionMode == Marketing::COMMISSION_MODE_RATE) { if ($commissionMode == Marketing::COMMISSION_MODE_RATE) {
$commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price; $commissionTotal = ($firstCommissionRate + $secondCommissionRate) / 10000 * $price;
......
...@@ -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
{ {
...@@ -26,9 +28,24 @@ class UserService ...@@ -26,9 +28,24 @@ class UserService
$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]);
} }
$redis = RedisUtil::getInstance('cache');
$key = "wx_wechat_login_".$code;
$keyCode = "wx_wechat_login_code_".$code;
$lock = FrequencyLockUtil::isLocked($key,1,120);
if ($lock) {
sleep(1);
$user = $redis->get($keyCode);
if (!empty($user)) {
$user = json_decode($user,true);
}
FileLog::error("wechatLogin: lock", json_encode($user, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
FileLog::error("wechatLogin: lock--params", json_encode($params, JSON_UNESCAPED_UNICODE),'','jianghaiming@yidian-inc.com');
return $user;
}
//需要授权微信 //需要授权微信
//if (empty($openid)) { //if (empty($openid)) {
...@@ -51,6 +68,7 @@ class UserService ...@@ -51,6 +68,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 +76,7 @@ class UserService ...@@ -58,7 +76,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 +86,13 @@ class UserService ...@@ -68,8 +86,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,17 +101,21 @@ class UserService ...@@ -78,17 +101,21 @@ 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]);
} }
$user['third_session'] = self::generate3rdSession($openid); $user['third_session'] = self::generate3rdSession($openid);
$redis->set($keyCode, json_encode($user),120);
return $user; return $user;
} }
...@@ -102,47 +129,47 @@ class UserService ...@@ -102,47 +129,47 @@ 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]);
} }
//解密 //解密
$decryptData = []; $decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey); $wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey);
$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]);
} }
...@@ -160,12 +187,16 @@ class UserService ...@@ -160,12 +187,16 @@ 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]);
} }
CommonService::isNewUser($params);
$isNewUser = CommonService::isNewUser(['openid' => $openid]); $isNewUser = CommonService::isNewUser(['openid' => $openid]);
if (!empty($isNewUser) && $isNewUser['is_new_user'] == 1) { if (!empty($isNewUser) && $isNewUser['is_new_user'] == 1) {
$userInfo['is_pop_up'] = 1; $userInfo['is_pop_up'] = 1;
...@@ -211,10 +242,17 @@ class UserService ...@@ -211,10 +242,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
...@@ -29,8 +29,10 @@ class Goods implements DaemonServiceInterface ...@@ -29,8 +29,10 @@ class Goods implements DaemonServiceInterface
GoodsSku::save($colums, $where); GoodsSku::save($colums, $where);
//更新es //更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']); GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
} }
$this->onlineGoods();
$this->onlineOffGoods();
} }
...@@ -53,4 +55,65 @@ class Goods implements DaemonServiceInterface ...@@ -53,4 +55,65 @@ class Goods implements DaemonServiceInterface
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']); GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
} }
} }
/**
*
* 自动上线
*/
public function onlineGoods()
{
sleep(2);
$orderData = [
'online_type' => 2,
'online_status' => [0,2],
'audit_status' => 1,
'online_start_time[<]' => date("Y-m-d H:i:s",time()),
'online_end_time[>]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$goodsList = GoodsSku::getRecords($orderData);
DaemonLog::info('DaemonServiceOnline_goods', json_encode($goodsList));
foreach ($goodsList as $key => $value) {
$where = [];
$where['goods_sku_id'] = !empty($value['goods_sku_id']) ? $value['goods_sku_id'] : '';
$colums = [
'online_status' => 1,
];
GoodsSku::save($colums, $where);
//更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
}
/**
*
* 自动下架
*/
public function onlineOffGoods()
{
sleep(2);
$orderData = [
'online_type' => 2,
'online_status' => 1,
'audit_status' => 1,
'online_end_time[<]' => date("Y-m-d H:i:s",time()),
'LIMIT' => 100,
];
$goodsList = GoodsSku::getRecords($orderData);
DaemonLog::info('DaemonServiceOnlineOff_goods', json_encode($goodsList));
foreach ($goodsList as $key => $value) {
$where = [];
$where['goods_sku_id'] = !empty($value['goods_sku_id']) ? $value['goods_sku_id'] : '';
$colums = [
'online_status' => 2,
];
GoodsSku::save($colums, $where);
//更新es
GoodsService::updateGoodsInfoToEs($where['goods_sku_id']);
}
}
} }
\ 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