Commit a4d37df8 authored by jianghaiming's avatar jianghaiming

Merge branch 'colonel' into test

parents ef07fcec 5b7ba7b4
......@@ -8,7 +8,7 @@ class ColonelDistributorPayInfo extends MysqlBase
{
const TABLE_NAME = 'colonel_distributor_pay_info';
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_FINISH_TARGET = 2;
......
......@@ -13,6 +13,7 @@ class MarketingPindan extends MysqlBase
const ACTIVITY_STATUS_NO_START = 1;
const ACTIVITY_STATUS_IN_PROGRESS = 2;
const ACTIVITY_STATUS_FINISHED = 3;
const ACTIVITY_STATUS_START_TODAY = 4;//今日上新
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
/**
* 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\PhpUtils\Log\FileLog;
use App\Base\Cli;
use App\Models\marketing\mysql\ColonelDistributorColonel;
use App\Models\marketing\mysql\ColonelDistributorConfig;
use App\Models\marketing\mysql\ColonelDistributorInviteOrderNum;
......@@ -11,10 +16,7 @@ use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\HttpUtil;
use App\Models\user\mysql\UserWechatBind;
/**
* php public/cli.php colonelorder index
*/
class ColonelorderController extends Cli
class ColonelOrderController extends Job
{
const DEFAULT_USER_BATCH_SIZE = 100;
......@@ -36,21 +38,25 @@ class ColonelorderController extends Cli
public function indexAction()
{
FileLog::info("colonel_distributor_order", '团长分销-计算奖励脚本:start');
$userIdList = $this->getColonelUserIds();
if (empty($userIdList) || empty($this->colonelConfigList)) {
return true;
}
if (!empty($userIdList)) {
$userIdList = array_chunk($userIdList, self::DEFAULT_USER_BATCH_SIZE);
$colonelPayInfoData = [];
foreach ($userIdList as $userIds) {
$batchPayInfoData = [];
// 完成目标单数
$batchPayInfoData[] = $this->getInviteOrderData($userIds);
if ($inviteOrderData = $this->getInviteOrderData($userIds)) {
$colonelPayInfoData = array_merge($colonelPayInfoData,$inviteOrderData);
}
// 邀请新用户奖励
$batchPayInfoData[] = $this->getInviteNewUserData($userIds);
$colonelPayInfoData = array_merge($colonelPayInfoData, $batchPayInfoData);
if ($inviteNewUserData = $this->getInviteNewUserData($userIds)) {
$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
*/
public function handleSavePayInfo($colonelPayInfoData)
{
FileLog::info("colonel_distributor_order", '团长分销-计算奖励脚本:colonelPayInfoCount='.count($colonelPayInfoData));
if (!empty($colonelPayInfoData)) {
$data = $this->addIdgenId($colonelPayInfoData);
try {
......@@ -113,8 +120,11 @@ class ColonelorderController extends Cli
public function getInviteOrderData($userIds)
{
//完成目标单数
$inviteOrderNumList = $this->getInviteOrderNum($userIds, $this->yesterday, $this->today);
$inviteOrderData = [];
if (empty($this->colonelConfigList)) {
return $inviteOrderData;
}
$inviteOrderNumList = $this->getInviteOrderNum($userIds, $this->yesterday, $this->today);
foreach ($inviteOrderNumList as $orderNum) {
foreach ($this->colonelConfigList as $config) {
if (!empty($orderNum["num"]) && $orderNum["num"] >= $config["assess_order_num"]) {
......@@ -181,7 +191,7 @@ class ColonelorderController extends Cli
[
"colonel_user_id" => $colonelUserIds,
"date[>=]" => $startTime,
"date[<=]" => $endTime,
"date[<]" => $endTime,
],
[]
);
......
<?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 App\Base\Cli;
use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use App\Exception\custom\InterfaceException;
use Api\PhpUtils\Http\HttpUtil;
/**
* php public/cli.php colonelwallet index
*/
class ColonelwalletController extends Cli
class ColonelWalletController extends Job
{
public function indexAction()
{
FileLog::info("colonel_distributor_wallet", '团长分销-奖励钱包脚本:start');
$yesterday = date("Y-m-d", strtotime("-1 day"));
$payInfoList = $this->getPayInfo($yesterday);
FileLog::info("colonel_distributor_wallet", '团长分销-奖励钱包脚本:payInfoCount='.count($payInfoList));
if (!empty($payInfoList)) {
if ($this->toWallet($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
*/
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
foreach ($result['result'] as &$applyVal) {
$applyVal['user_avatar'] = !empty($userMap[$applyVal['user_id']]['user_avatar']) ? $userMap[$applyVal['user_id']]['user_avatar'] : '';
// take_place_status 是否可以添加自提点 - 已审核通过并且未添加过自提点
$applyVal['take_place_status'] = 0;
$applyVal['take_place_status'] = 2;
if ($applyVal['audit_status'] == ColonelDistributorColonelApply::STATUS_PASS) {
if (empty($takePlaceMap[$applyVal['colonel_apply_id']]['take_place_id'])) {
$applyVal['take_place_status'] = 1;
......
......@@ -273,6 +273,17 @@ class MarketingService
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$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;
if (!empty($params['marketing_name'])) {
......@@ -288,18 +299,27 @@ class MarketingService
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS) {
$where["start_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) {
$where["end_time[<]"] = $now;
}
if (!empty($params['from'])) {
//七日内结束的活动
if (!empty($params['from']) && $params['from'] == 1) {
$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['ORDER'] = ["update_time" => "DESC"];
$where['ORDER'] = [$sortField => $sortType];
$where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
"online_status", "update_time", "create_time"]
......@@ -1085,6 +1105,7 @@ class MarketingService
$allHaveBuyGoodsSkuIds = array_keys($allHaveBuyGoodsStatistics);
if (in_array($item["goods_sku_id"], $allHaveBuyGoodsSkuIds)) {
$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
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)
{
$openid = !empty($params['openid']) ? $params['openid'] : '';
$encryptedData = !empty($params['encryptedData']) ? $params['encryptedData'] : '';
$iv = !empty($params['iv']) ? $params['iv'] : '';
......@@ -116,19 +122,11 @@ class UserService
throw new UserException(['cus' => 5]);
}
//解密
$decryptData = [];
$wXBizDataCrypt = new WxBizDataCrypt($appid, $sessionKey);
$errCode = $wXBizDataCrypt->decryptData($encryptedData, $iv, $decryptData);
if ($errCode) {
throw new UserException(['cus' => 6]);
}
......@@ -139,7 +137,6 @@ class UserService
}
$phoneNumber = strval($decryptData['phoneNumber']);
//判断是否已
$user = UserWechatBind::getRecord(['phone' => $phoneNumber]);
if (!empty($user) && $openid != $user['openid']) {
......@@ -164,8 +161,6 @@ class UserService
throw new UserException(['cus' => 8]);
}
CommonService::isNewUser($params);
$isNewUser = CommonService::isNewUser(['openid' => $openid]);
if (!empty($isNewUser) && $isNewUser['is_new_user'] == 1) {
$userInfo['is_pop_up'] = 1;
......
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"
\ No newline at end of file
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
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
\ No newline at end of file
......@@ -35,6 +35,9 @@ if ($param) {
$_SERVER['SERVER_NAME'] = 'daemon.goods';
$_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));
......
......@@ -35,6 +35,9 @@ if ($param) {
$_SERVER['SERVER_NAME'] = 'job.goods';
$_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));
......
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