Commit a4d37df8 authored by jianghaiming's avatar jianghaiming

Merge branch 'colonel' into test

parents ef07fcec 5b7ba7b4
...@@ -8,7 +8,7 @@ class ColonelDistributorPayInfo extends MysqlBase ...@@ -8,7 +8,7 @@ class ColonelDistributorPayInfo extends MysqlBase
{ {
const TABLE_NAME = 'colonel_distributor_pay_info'; const TABLE_NAME = 'colonel_distributor_pay_info';
const CONFIG_INDEX = 'marketing'; const CONFIG_INDEX = 'marketing';
const PRIMARY_KEY = 'colonel_distributor_pay_info_id'; const PRIMARY_KEY = 'pay_info_id';
const TYPE_NEW_USER = 1; const TYPE_NEW_USER = 1;
const TYPE_FINISH_TARGET = 2; const TYPE_FINISH_TARGET = 2;
......
...@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase ...@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase
const ACTIVITY_STATUS_NO_START = 1; const ACTIVITY_STATUS_NO_START = 1;
const ACTIVITY_STATUS_IN_PROGRESS = 2; const ACTIVITY_STATUS_IN_PROGRESS = 2;
const ACTIVITY_STATUS_FINISHED = 3; const ACTIVITY_STATUS_FINISHED = 3;
const ACTIVITY_STATUS_START_TODAY = 4;//今日上新
public static function getRecord($where, $colums = []) public static function getRecord($where, $colums = [])
{ {
......
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 1:36 下午
*/
use App\Base\Job;
class ColonelOrderController extends Job
{
public function indexAction()
{
\Yaf\Application::app()->bootstrap()->getDispatcher()->dispatch(new \Yaf\Request\Simple('', 'cli', 'colonelorder', 'index', []));
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 2:28 下午
*/
use App\Base\Job;
class ColonelWalletController extends Job
{
public function indexAction()
{
\Yaf\Application::app()->bootstrap()->getDispatcher()->dispatch(new \Yaf\Request\Simple('', 'cli', 'colonelwallet', 'index', []));
}
}
\ No newline at end of file
<?php <?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 1:36 下午
*/
use App\Base\Job;
use Api\PhpServices\Idgen\Idgen; use Api\PhpServices\Idgen\Idgen;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
use App\Base\Cli;
use App\Models\marketing\mysql\ColonelDistributorColonel; use App\Models\marketing\mysql\ColonelDistributorColonel;
use App\Models\marketing\mysql\ColonelDistributorConfig; use App\Models\marketing\mysql\ColonelDistributorConfig;
use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum; use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum;
...@@ -11,10 +16,7 @@ use App\Exception\custom\InterfaceException; ...@@ -11,10 +16,7 @@ use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\HttpUtil; use Api\PhpUtils\Http\HttpUtil;
use App\Models\user\mysql\UserWechatBind; use App\Models\user\mysql\UserWechatBind;
/** class ColonelOrderController extends Job
* php public/cli.php colonelorder index
*/
class ColonelorderController extends Cli
{ {
const DEFAULT_USER_BATCH_SIZE = 100; const DEFAULT_USER_BATCH_SIZE = 100;
...@@ -36,21 +38,25 @@ class ColonelorderController extends Cli ...@@ -36,21 +38,25 @@ class ColonelorderController extends Cli
public function indexAction() public function indexAction()
{ {
FileLog::info("colonel_distributor_order", '团长分销-计算奖励脚本:start');
$userIdList = $this->getColonelUserIds(); $userIdList = $this->getColonelUserIds();
if (empty($userIdList) || empty($this->colonelConfigList)) { if (!empty($userIdList)) {
return true;
}
$userIdList = array_chunk($userIdList, self::DEFAULT_USER_BATCH_SIZE); $userIdList = array_chunk($userIdList, self::DEFAULT_USER_BATCH_SIZE);
$colonelPayInfoData = []; $colonelPayInfoData = [];
foreach ($userIdList as $userIds) { foreach ($userIdList as $userIds) {
$batchPayInfoData = [];
// 完成目标单数 // 完成目标单数
$batchPayInfoData[] = $this->getInviteOrderData($userIds); if ($inviteOrderData = $this->getInviteOrderData($userIds)) {
$colonelPayInfoData = array_merge($colonelPayInfoData,$inviteOrderData);
}
// 邀请新用户奖励 // 邀请新用户奖励
$batchPayInfoData[] = $this->getInviteNewUserData($userIds); if ($inviteNewUserData = $this->getInviteNewUserData($userIds)) {
$colonelPayInfoData = array_merge($colonelPayInfoData, $batchPayInfoData); $colonelPayInfoData = array_merge($colonelPayInfoData,$inviteNewUserData);
} }
return $this->handleSavePayInfo($colonelPayInfoData); }
$this->handleSavePayInfo($colonelPayInfoData);
}
FileLog::info("colonel_distributor_order", '团长分销-计算奖励脚本:end');
echo "success";
} }
/** /**
...@@ -60,6 +66,7 @@ class ColonelorderController extends Cli ...@@ -60,6 +66,7 @@ class ColonelorderController extends Cli
*/ */
public function handleSavePayInfo($colonelPayInfoData) public function handleSavePayInfo($colonelPayInfoData)
{ {
FileLog::info("colonel_distributor_order", '团长分销-计算奖励脚本:colonelPayInfoCount='.count($colonelPayInfoData));
if (!empty($colonelPayInfoData)) { if (!empty($colonelPayInfoData)) {
$data = $this->addIdgenId($colonelPayInfoData); $data = $this->addIdgenId($colonelPayInfoData);
try { try {
...@@ -113,8 +120,11 @@ class ColonelorderController extends Cli ...@@ -113,8 +120,11 @@ class ColonelorderController extends Cli
public function getInviteOrderData($userIds) public function getInviteOrderData($userIds)
{ {
//完成目标单数 //完成目标单数
$inviteOrderNumList = $this->getInviteOrderNum($userIds, $this->yesterday, $this->today);
$inviteOrderData = []; $inviteOrderData = [];
if (empty($this->colonelConfigList)) {
return $inviteOrderData;
}
$inviteOrderNumList = $this->getInviteOrderNum($userIds, $this->yesterday, $this->today);
foreach ($inviteOrderNumList as $orderNum) { foreach ($inviteOrderNumList as $orderNum) {
foreach ($this->colonelConfigList as $config) { foreach ($this->colonelConfigList as $config) {
if (!empty($orderNum["num"]) && $orderNum["num"] >= $config["assess_order_num"]) { if (!empty($orderNum["num"]) && $orderNum["num"] >= $config["assess_order_num"]) {
...@@ -181,7 +191,7 @@ class ColonelorderController extends Cli ...@@ -181,7 +191,7 @@ class ColonelorderController extends Cli
[ [
"colonel_user_id" => $colonelUserIds, "colonel_user_id" => $colonelUserIds,
"date[>=]" => $startTime, "date[>=]" => $startTime,
"date[<=]" => $endTime, "date[<]" => $endTime,
], ],
[] []
); );
......
<?php <?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/8/31 2:28 下午
*/
use App\Base\Job;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
use App\Base\Cli;
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;
/** class ColonelWalletController extends Job
* php public/cli.php colonelwallet index
*/
class ColonelwalletController extends Cli
{ {
public function indexAction() public function indexAction()
{ {
FileLog::info("colonel_distributor_wallet", '团长分销-奖励钱包脚本:start');
$yesterday = date("Y-m-d", strtotime("-1 day")); $yesterday = date("Y-m-d", strtotime("-1 day"));
$payInfoList = $this->getPayInfo($yesterday); $payInfoList = $this->getPayInfo($yesterday);
FileLog::info("colonel_distributor_wallet", '团长分销-奖励钱包脚本:payInfoCount='.count($payInfoList));
if (!empty($payInfoList)) { if (!empty($payInfoList)) {
if ($this->toWallet($payInfoList)) {
if ($this->deductingInventory($payInfoList)) { if ($this->deductingInventory($payInfoList)) {
$this->handlePayInfoStatus(array_column($payInfoList, 'colonel_distributor_pay_info_id')); if ($this->toWallet($payInfoList)) {
$this->handlePayInfoStatus(array_column($payInfoList, 'pay_info_id'));
} }
} }
} }
FileLog::info("colonel_distributor_wallet", '团长分销-奖励钱包脚本:end');
echo "success";
} }
/** /**
...@@ -129,6 +135,6 @@ class ColonelwalletController extends Cli ...@@ -129,6 +135,6 @@ class ColonelwalletController extends Cli
*/ */
public function handlePayInfoStatus(array $payInfoIds) public function handlePayInfoStatus(array $payInfoIds)
{ {
return ColonelDistributorPayInfo::updateRecord(['status' => ColonelDistributorPayInfo::STATUS_USE], ['id' => $payInfoIds]); return ColonelDistributorPayInfo::updateRecord(['status' => ColonelDistributorPayInfo::STATUS_USE], ['pay_info_id' => $payInfoIds]);
} }
} }
\ No newline at end of file
...@@ -93,7 +93,7 @@ class ColonelService ...@@ -93,7 +93,7 @@ class ColonelService
foreach ($result['result'] as &$applyVal) { foreach ($result['result'] as &$applyVal) {
$applyVal['user_avatar'] = !empty($userMap[$applyVal['user_id']]['user_avatar']) ? $userMap[$applyVal['user_id']]['user_avatar'] : ''; $applyVal['user_avatar'] = !empty($userMap[$applyVal['user_id']]['user_avatar']) ? $userMap[$applyVal['user_id']]['user_avatar'] : '';
// take_place_status 是否可以添加自提点 - 已审核通过并且未添加过自提点 // take_place_status 是否可以添加自提点 - 已审核通过并且未添加过自提点
$applyVal['take_place_status'] = 0; $applyVal['take_place_status'] = 2;
if ($applyVal['audit_status'] == ColonelDistributorColonelApply::STATUS_PASS) { if ($applyVal['audit_status'] == ColonelDistributorColonelApply::STATUS_PASS) {
if (empty($takePlaceMap[$applyVal['colonel_apply_id']]['take_place_id'])) { if (empty($takePlaceMap[$applyVal['colonel_apply_id']]['take_place_id'])) {
$applyVal['take_place_status'] = 1; $applyVal['take_place_status'] = 1;
......
...@@ -273,6 +273,17 @@ class MarketingService ...@@ -273,6 +273,17 @@ class MarketingService
$params['page'] = !empty($params['page']) ? $params['page'] : 1; $params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20; $limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit; $page = ($params['page'] - 1) * $limit;
//排序规则
$sortField = $params['sort_field'] ?? 'update_time';
$sortType = isset($params['sort_type']) ? strtoupper($params['sort_type']) : 'desc';
//验证sort合法性
if(!in_array($params['sort_field'],['create_time','update_time','end_time','start_time'])) {
$sortField = 'update_time';
}
if(!in_array($params['sort_type'],['asc','desc'])) {
$sortType = 'DESC';
}
$where["marketing_type"] = Marketing::MARKETING_TYPE_PINDAN; $where["marketing_type"] = Marketing::MARKETING_TYPE_PINDAN;
if (!empty($params['marketing_name'])) { if (!empty($params['marketing_name'])) {
...@@ -288,18 +299,27 @@ class MarketingService ...@@ -288,18 +299,27 @@ class MarketingService
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS) { } elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS) {
$where["start_time[<=]"] = $now; $where["start_time[<=]"] = $now;
$where["end_time[>=]"] = $now; $where["end_time[>=]"] = $now;
//七日内开始的活动
if (!empty($params['from']) && $params['from'] == 1) {
$beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day"));
$where["start_time[>]"] = $beforeSevenDay;
}
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_FINISHED) { } elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_FINISHED) {
$where["end_time[<]"] = $now; $where["end_time[<]"] = $now;
} //七日内结束的活动
if (!empty($params['from']) && $params['from'] == 1) {
if (!empty($params['from'])) {
$beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day")); $beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day"));
$where["start_time[>]"] = $beforeSevenDay; $where["end_time[>]"] = $beforeSevenDay;
}
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_START_TODAY) {//今日上新-未开始
$where["start_time[>]"] = $now;
$where["start_time[<=]"] = date("Y-m-d 00:00:00",strtotime('+1 days'));
$where["end_time[>=]"] = $now;
} }
$where['life_account_id'] = self::getPublicLifeAccountId(); $where['life_account_id'] = self::getPublicLifeAccountId();
$where['ORDER'] = ["update_time" => "DESC"]; $where['ORDER'] = [$sortField => $sortType];
$where['LIMIT'] = [$page, $limit]; $where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time", $list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
"online_status", "update_time", "create_time"] "online_status", "update_time", "create_time"]
...@@ -1085,6 +1105,7 @@ class MarketingService ...@@ -1085,6 +1105,7 @@ class MarketingService
$allHaveBuyGoodsSkuIds = array_keys($allHaveBuyGoodsStatistics); $allHaveBuyGoodsSkuIds = array_keys($allHaveBuyGoodsStatistics);
if (in_array($item["goods_sku_id"], $allHaveBuyGoodsSkuIds)) { if (in_array($item["goods_sku_id"], $allHaveBuyGoodsSkuIds)) {
$goodsSkuList[$key]["all_have_buy_goods_count"] = $allHaveBuyGoodsStatistics[$item["goods_sku_id"]]; $goodsSkuList[$key]["all_have_buy_goods_count"] = $allHaveBuyGoodsStatistics[$item["goods_sku_id"]];
$goodsSkuList[$key]["total_amount_sold"] = $allHaveBuyGoodsStatistics[$item["goods_sku_id"]];
} }
} }
......
...@@ -92,10 +92,16 @@ class UserService ...@@ -92,10 +92,16 @@ class UserService
return $user; return $user;
} }
/**
* 绑定手机号
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws UserException
* @throws \App\Exception\custom\CodeSpecialException
* @throws \App\Exception\custom\InterfaceException
*/
public static function bindPhone($params) public static function bindPhone($params)
{ {
$openid = !empty($params['openid']) ? $params['openid'] : ''; $openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : ''; $encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : '';
$iv = !empty($params['iv']) ? $params['iv'] : ''; $iv = !empty($params['iv']) ? $params['iv'] : '';
...@@ -116,19 +122,11 @@ class UserService ...@@ -116,19 +122,11 @@ class UserService
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) {
throw new UserException(['cus' => 6]); throw new UserException(['cus' => 6]);
} }
...@@ -139,7 +137,6 @@ class UserService ...@@ -139,7 +137,6 @@ class UserService
} }
$phoneNumber = strval($decryptData['phoneNumber']); $phoneNumber = strval($decryptData['phoneNumber']);
//判断是否已 //判断是否已
$user = UserWechatBind::getRecord(['phone' => $phoneNumber]); $user = UserWechatBind::getRecord(['phone' => $phoneNumber]);
if (!empty($user) && $openid != $user['openid']) { if (!empty($user) && $openid != $user['openid']) {
...@@ -164,8 +161,6 @@ class UserService ...@@ -164,8 +161,6 @@ class UserService
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;
......
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" 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"
\ 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" 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"
dependencies=run-colonel-order dependencies=run-colonel-order
\ No newline at end of file
...@@ -35,6 +35,9 @@ if ($param) { ...@@ -35,6 +35,9 @@ if ($param) {
$_SERVER['SERVER_NAME'] = 'daemon.goods'; $_SERVER['SERVER_NAME'] = 'daemon.goods';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
if (empty($_SERVER['SERVER_ADDR'])) {
$_SERVER['SERVER_ADDR'] = 'azkaban-127.0.0.1';
}
$application->bootstrap()->getDispatcher()->dispatch(new Yaf\Request\Simple("", $module, $controller, $method, $param)); $application->bootstrap()->getDispatcher()->dispatch(new Yaf\Request\Simple("", $module, $controller, $method, $param));
......
...@@ -35,6 +35,9 @@ if ($param) { ...@@ -35,6 +35,9 @@ if ($param) {
$_SERVER['SERVER_NAME'] = 'job.goods'; $_SERVER['SERVER_NAME'] = 'job.goods';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
if (empty($_SERVER['SERVER_ADDR'])) {
$_SERVER['SERVER_ADDR'] = 'azkaban-127.0.0.1';
}
$application->bootstrap()->getDispatcher()->dispatch(new Yaf\Request\Simple("", $module, $controller, $method, $param)); $application->bootstrap()->getDispatcher()->dispatch(new Yaf\Request\Simple("", $module, $controller, $method, $param));
......
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