Merge branch 'dev' into preview

This commit is contained in:
chenbo 2023-11-22 14:05:26 +08:00
commit 759a9d4eb5
13 changed files with 585 additions and 165 deletions

View File

@ -36,7 +36,7 @@ class ApproveController extends BaseAdminController
public function audit()
{
try {
$params = $this->request->param(); // id check_status remark
$params = $this->request->param(); // id check_status remark amount
$approve = Approve::find($params['id']);
if (!$approve) {
$this->fail('数据不存在');
@ -57,7 +57,7 @@ class ApproveController extends BaseAdminController
$this->fail('该任务提前完成条件销售总额必须达到30万元及以上');
} else {
// 提前完成标识
$extend = json_decode($taskTemplate['extend'], true);
$extend = $taskTemplate['extend'];
$extend['early_finish'] = 1;
$taskTemplate->extend = json_encode($extend);
$taskTemplate->save();
@ -67,7 +67,7 @@ class ApproveController extends BaseAdminController
$this->pass($approve, $params);
}
} else {
$this->pass($approve);
$this->pass($approve, $params);
}
}
@ -135,13 +135,21 @@ class ApproveController extends BaseAdminController
// 需要手动输入申请的政策补贴金额
$approve->amount = $params['amount'];
$approve->save();
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
->where('is_pay',0)
->with(['template_info'])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 41)
->find()
->toArray();
TaskLogic::masterTask7Settlement($taskSchedulePlan);
}
if ($approve->type == Approve::APPROVE_TYPE_9) {
$taskSchedulePlan = TaskSchedulingPlan::where('la_task_scheduling_plan.id', $task['scheduling_plan_id'])
->where('is_pay',0)
->with(['template_info'])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 17)
->where('scheduling.company_type', 41)
->find()
->toArray();
TaskLogic::masterTask8Settlement($taskSchedulePlan);

View File

@ -7,6 +7,7 @@ use app\adminapi\validate\CompanyValidate;
use app\common\logic\contract\ContractLogic;
use app\common\logic\finance\ShareProfit;
use app\common\logic\RedisLogic;
use app\common\logic\ShopRequestLogic;
use app\common\logic\task\TaskLogic;
use app\common\model\Company;
use app\common\model\contract\Contract;
@ -16,6 +17,9 @@ use app\common\model\task_scheduling_plan\TaskSchedulingPlan;
use app\common\model\task_template\TaskTemplate;
use app\job\TaskAdd;
use app\job\TaskInformationJob;
use app\job\VillageTaskAdd;
use app\job\VillageTaskSettlementJob;
use think\Exception;
use think\facade\Log;
use app\job\TaskTenZehn;
use think\facade\Db;
@ -36,6 +40,12 @@ class CeshiController extends BaseApiController
'initiate_contract', // 发起合同
'Draftingcontracts', // 发送合同
'postsms', // 发送短信
'addSupplyMerchant', // 添加供应商
'signSupplyMerchantContract', // 生成合同
'countRate',
'village_task_add_test',
'village_task_settlement_test',
'testShopApi'
];
public function index()
@ -250,18 +260,22 @@ class CeshiController extends BaseApiController
public function service_group_task_add_test()
{
//任务下发
$companyId = $this->request->param('company_id');
$time = strtotime(date('Y-m-d')); // 今天的000000
// 注意 cron_time
$plan_all = TaskScheduling::where('cron_time', '<', $time)
$plan_all = TaskScheduling::where('cron_time', '<', time())
->where('status', 1)
->where('company_type', 18)
->where('company_id', $companyId)
->with('company_info')
->select()
->toArray();
dd($plan_all);
$plan_ids = [];
dd($plan_all);
foreach ($plan_all as $k => $v) {
$all = TaskTemplate::where('status', 1)->where('task_scheduling', $v['id'])->limit(30)->select()->toArray();
$plan_ids[] = $v['id'];
if ($all) {
$plan_all[$k]['template'] = $all;
@ -292,12 +306,12 @@ class CeshiController extends BaseApiController
$all = TaskSchedulingPlan::whereDay('end_time','today')
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 18)
->where('scheduling.company_id', 43)
->where('is_pay',0)
->with(['template_info'])
->select()
->toArray();
dd($all);
foreach($all as $k=>$data){
try {
TaskSchedulingPlan::where('id', $data['id'])->update(['is_pay' => 1]);
@ -454,20 +468,32 @@ class CeshiController extends BaseApiController
public function town_task_add_ceshi()
{
//任务下发
$companyId = $this->request->param('company_id');
$taskTypeIds = $this->request->param('task_type_ids');
$time = strtotime(date('Y-m-d'));
// 查询系统 所有镇农科公司 未下发 的 任务安排
$taskSchedulingList = TaskScheduling::where('cron_time', '<', $time)->where('status', 1)->where('company_type', 41)->with('company_info')->select()->toArray();
dd($taskSchedulingList);
$taskSchedulingList = TaskScheduling::where('cron_time', '<', time())
->where('status', 1)
->where('company_type', 41)
->where('company_id', $companyId)
->with('company_info')
->select()
->toArray();
$taskSchedulingIds = [];
$companyIds = [];
foreach ($taskSchedulingList as $k => $taskScheduling) {
$templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray();
$taskSchedulingIds[] = $taskScheduling['id'];
$companyIds[] = $taskScheduling['company_id'];
foreach ($templateList as $template) {
if (in_array($template['type'], explode(',', $taskTypeIds))) {
TaskLogic::TownCronAdd($template); // 手动下发用
}
// queue(TownTaskAdd::class, $template);
TaskLogic::TownCronAdd($template); // 手动下发用
}
if (empty($templateList)) {
@ -477,6 +503,7 @@ class CeshiController extends BaseApiController
Company::where('id', 'in', $companyIds)->inc('day_count')->update();
TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]);
Log::info('定时任务下发执行成功' . date('Y-m-d H:i:s'));
return $this->success('定时任务下发执行成功');
}
/**
@ -494,10 +521,199 @@ class CeshiController extends BaseApiController
->toArray();
dd($taskSchedulingPlanList);
foreach($taskSchedulingPlanList as $taskSchedulingPlan) {
if (in_array($taskSchedulingPlan['template_info']['type'], [44,45,46,47,48,49,50])) {
continue;
if ($taskSchedulingPlan['company_id'] == 30 && $taskSchedulingPlan['template_info']['type'] == 50) {
TaskLogic::townTaskSettlement($taskSchedulingPlan);
}
TaskLogic::townTaskSettlement($taskSchedulingPlan);
}
return $this->success('镇农科公司定时任务结算执行成功');
}
/**
* 村管理公司任务下发
*/
public function village_task_add_test()
{
//任务下发
$time = strtotime(date('Y-m-d'));
// 查询系统 所有镇农科公司 未下发 的 任务安排
$taskSchedulingList = TaskScheduling::where('cron_time', '<', time())
->where('status', 1)
->where('company_type', 17)
->where('company_id', 33)
->with('company_info')
->select()
->toArray();
dd($taskSchedulingList);
$taskSchedulingIds = [];
$companyIds = [];
foreach ($taskSchedulingList as $k => $taskScheduling) {
$templateList = TaskTemplate::where('status', 1)->where('task_scheduling', $taskScheduling['id'])->limit(30)->select()->toArray();
$taskSchedulingIds[] = $taskScheduling['id'];
$companyIds[] = $taskScheduling['company_id'];
foreach ($templateList as $template) {
if ($template['type'] == 69) {
TaskLogic::VillageCronAdd($template); // 手动下发用
}
// queue(VillageTaskAdd::class, $template);
}
if (empty($templateList)) {
unset($taskSchedulingList[$k]);
}
}
Company::where('id', 'in', $companyIds)->inc('day_count')->update();
TaskScheduling::where('id', 'in', $taskSchedulingIds)->update(['cron_time' => time()]);
Log::info('村管理公司定时任务下发执行成功' . date('Y-m-d H:i:s'));
return $this->success('村管理公司定时任务下发执行成功');
}
/**
* 村管理公司任务结算
*/
public function village_task_settlement_test()
{
Log::info('村管理公司定时任务结算执行-开始'.date('Y-m-d H:i:s'));
//today 今日未结算的任务计划
$taskSchedulingPlanList = TaskSchedulingPlan::whereDay('end_time','today')
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 17)
->where('scheduling.company_id', 33)
->where('is_pay',0)
->with(['template_info'])
->select()
->toArray();
dd($taskSchedulingPlanList);
foreach($taskSchedulingPlanList as $taskSchedulingPlan){
if ($taskSchedulingPlan['template_info']['type'] == 69) {
TaskLogic::villageTaskSettlement($taskSchedulingPlan);
}
// queue(VillageTaskSettlementJob::class, $taskSchedulingPlan);
}
Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
return $this->success('村管理公司定时任务结算执行成功');
}
public function countRate()
{
// 第一个月
$startTime1 = strtotime(date('Y-m-d', time())); // 任务下发当天 00:00:00
$endTime1 = strtotime("+30 day", $startTime1); // 30天后的00:0000
// 第二个月
$startTime2 = strtotime(date('Y-m-d', $endTime1)); // 第一个月截止日 00:00:00
$endTime2 = strtotime("+30 day", $startTime2); // 30天后的00:0000
dd([date('Y-m-d H:i:s', $startTime1), date('Y-m-d H:i:s', $endTime1), date('Y-m-d H:i:s', $startTime2), date('Y-m-d H:i:s', $endTime2)]);
$procureAmount = 1234;
$step = $this->request->param('step', 1);
// 商户入驻至今累计天数
$targetProcureAmount = 10000;
// 目标采购额每阶段增幅30%
for ($i = 1; $i < $step; $i++) {
$targetProcureAmount = self::increase($targetProcureAmount);
}
dd($targetProcureAmount);
$rate = bcdiv($procureAmount, $targetProcureAmount, 2);
return $rate;
}
private static function increase($value)
{
return bcmul($value, 1.3,2);
}
/**
* 添加供应链商户
*/
public function addSupplyMerchant()
{
try {
// 添加商户数据
$params = $this->request->param();
$data = [
'mer_intention_id' => 0, // 商城商户入驻申请id签约完成后回调使用
'company_name' => $params['company_name']??'',
'mer_name' => $params['mer_name']??'', // 店铺名称
'organization_code' => $params['organization_code']??'',
'city' => $params['city']??'',
'area' => $params['area']??'',
'street' => $params['street']??'',
'address' => $params['address']??'',
'master_name' => $params['master_name']??'',
'master_phone' => $params['master_phone']??'',
'master_email' => $master_email??'',
'type_name' => $params['type_name'] ?? '', //店铺类型
'category_name' => $params['category_name'] ?? '', //商户分类
'qualification' => !empty($params['images'])?$params['images']:json_encode([])
];
$shopMerchantModel = ShopMerchant::create($data);
$shopMerchantCertificationData = [
'name' => $shopMerchantModel->company_name,
'organization_code' => $shopMerchantModel->organization_code,
'business_license' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/561f8202305171526091317.png',
'master_name' => $shopMerchantModel->master_name,
'master_email' => $shopMerchantModel->master_email,
'master_phone' => $shopMerchantModel->master_phone,
'id' => $shopMerchantModel->id,
];
$re = app(JunziqianController::class)->ShopMerchantCertification($shopMerchantCertificationData);
return $this->success('成功', $shopMerchantModel->toArray());
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
// 生成合同
public function signSupplyMerchantContract()
{
try {
$params = $this->request->param();
// 生成合同
$createContractData = [
'id' => $params['id'],
'party_a' => $params['party_a'],
'party_a_name' => $params['party_a_name'],
'party_b' => $params['party_b'],
'party_b_name' => $params['party_b_name'],
'contract_type' => 58, // 供应链商户合同
];
$model = new ShopContract();
$model->contract_no = time();
$model->create_time = time();
$model->check_status = 1;
$model->update_time = time();
$model->setAttrs($createContractData);
$res = $model->save($createContractData);
return $this->success('成功', $res->toArray());
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
public function testShopApi()
{
$id = $this->request->param('id');
$templateInfo = TaskTemplate::where(['id'=>$id])->find();
$townCompany = Company::where(['id' => $templateInfo['company_id']])->find();
$param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400;
$param['end_time'] = time();
$param['mer_intention_id'] = 131;
// $param['goods_id'] = '17,18';
$param['type_id'] = 10;
// todo 返回字段要对接
$result = ShopRequestLogic::getGeneralMerchantProductListing($param);
dd($result);
}
}

View File

@ -16,8 +16,11 @@ namespace app\api\controller;
use app\api\validate\PayValidate;
use app\common\enum\PayEnum;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\PaymentLogic;
use app\common\logic\PayRequestLogic;
use app\common\model\Company;
use app\common\service\pay\WeChatPayService;
use think\facade\Log;
@ -62,13 +65,23 @@ class PayController extends BaseApiController
if (false === $order) {
return $this->fail(PaymentLogic::getError(), $params);
}
//支付流程
$redirectUrl = $params['redirect'] ?? '/pages/payment/payment';
$result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl);
// 请求支付系统
$companyInfo = Company::where(['id' => $this->userInfo['company_id']])->find();
$requestData = [
'street' => $companyInfo['street'],
'order_from' => 12,
'order_type' => 101,
'pay_user_role' => $this->userInfo['group_id'],
'pay_user_info' => $this->userInfo,
'business_order_no' => $order['sn'],
'total_fee' => intval(bcmul($order['order_amount'], 100)),
'business_callback_url' => (string)url('pay/notifyApp', [], false, true)
];
$result = PayRequestLogic::getPrePayId($requestData);
if (false === $result) {
return $this->fail(PaymentLogic::getError(), $params);
}
return $this->success('', $result);
return $this->success('', $result['data']);
}
@ -122,18 +135,18 @@ class PayController extends BaseApiController
/**
* @notes app支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @notes 支付系统回调
* @date 2023/2/28 14:21
*/
public function notifyApp()
{
return (new WeChatPayService(UserTerminalEnum::ANDROID))->notify();
try {
$param = $this->request->param();
Log::info(['支付系统回调', $param]);
(new WeChatPayService(UserTerminalEnum::ANDROID))->notify($param);
return $this->success('ok');
} catch (\Exception $e) {
return $this->fail($e->getMessage());
}
}
}

View File

@ -94,6 +94,9 @@ class TaskController extends BaseApiController
if (isset($townMasterTaskTypeList[$item['type']])) {
$res[$k]['task_type_value'] = $townMasterTaskTypeList[$item['type']];
}
if (isset($townMarketingManagerTaskTypeList[$item['type']])) {
$res[$k]['task_type_value'] = $townMarketingManagerTaskTypeList[$item['type']];
}
if ($item['type'] == 33) {
$company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足
@ -444,7 +447,7 @@ class TaskController extends BaseApiController
$stage = $parmas['stage']; // 当前做的是任务第几阶段
if ($stage == 1) {
$extend['stage1'] = $parmas['stage1'];
$parmas['stage1']['is_commit'] = 1;
$extend['stage1']['is_commit'] = 1;
}
if ($stage == 2) {
$extend['stage2'] = $parmas['stage2'];
@ -674,7 +677,7 @@ class TaskController extends BaseApiController
$task = Task::where(['id'=>$param['id']])->find();
$taskTemplate = TaskTemplate::where(['id'=>$task['template_id']])->find();
$extend = $taskTemplate['extend'];
$extend['purchase_sales_info'][] = $param['purchase_sales_info'];
$extend['purchase_sales_info'] = $param['purchase_sales_info'];
$taskTemplate->save(['extend'=>json_encode($extend)]);
return $this->success('成功', []);
}
@ -712,7 +715,62 @@ class TaskController extends BaseApiController
// 没有则创建审批任务
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
if ($approveModel->isEmpty()) {
$approveModel->type = Approve::APPROVE_TYPE_6;
$approveModel->type = Approve::APPROVE_TYPE_8;
$approveModel->flow_id = 1;
$approveModel->name = $task['title'];
$approveModel->admin_id = 0; // 后台发起人id 暂时为0
$approveModel->user_id = $this->userId; // 前台发起人用户id
$approveModel->task_id = $task['id']; // 任务id
$approveModel->department_id = '0';
$approveModel->check_admin_ids = $areaManagerId; // 当前审批人ID 片区经理的admin_id
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
$approveModel->other_type = 6;
$approveModel->extend = json_encode($extend);
$approveModel->create_time = time();
$approveModel->update_time = time();
$re = $approveModel->save();
} else {
// 有则更新状态
$approveModel->check_status = 1; // 状态 0待审核,1审核中,2审核通过,3审核不通过,4撤销审核
$approveModel->save();
}
return $this->success('ok', []);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
public function commit_town_master_task_type_8()
{
try {
$parmas = $this->request->param(); // id annex video_annex
$task = TaskLogic::detail($parmas);
if (empty($task)) {
$this->fail('任务不存在');
}
if (empty($parmas['annex']) && empty($parmas['video_annex'])) {
$this->fail('没有上传凭证,无法提交审核');
}
$extend = [
'other'=> [
'is_commit' => 1,
'note' => $parmas['note'],
'annex' => $parmas['annex'],
'video_annex' => $parmas['video_annex'],
]
];
Task::where(['id' => $parmas['id']])->update(['extend' => json_encode($extend), 'update_time'=>time(), 'director_uid'=>$this->userId]); // director_uid 指派人
// 片区经理
$areaManagerId = User::where(['id' => $this->userId])->with('company')->value('area_manager');
// 没有则创建审批任务
$approveModel = Approve::where(['task_id' => $task['id']])->findOrEmpty();
if ($approveModel->isEmpty()) {
$approveModel->type = Approve::APPROVE_TYPE_9;
$approveModel->flow_id = 1;
$approveModel->name = $task['title'];
$approveModel->admin_id = 0; // 后台发起人id 暂时为0

View File

@ -140,6 +140,9 @@ class LoginLogic extends BaseLogic
if (isset($params['register_id']) && $params['register_id'] != '') {
$user->register_id = $params['register_id'];
}
if (isset($params['ytj_register_id']) && $params['ytj_register_id'] != '') {
$user->ytj_register_id = $params['ytj_register_id'];
}
//更新登录信息
$user->login_time = time();
$user->login_ip = request()->ip();

View File

@ -67,6 +67,7 @@ class PayNotifyLogic extends BaseLogic
$order = RechargeOrder::where('sn', $orderSn)->findOrEmpty();
if ($order && isset($order['extend']['type']) && $order['extend']['type'] == 1) {
// ***** 小组服务团队-入股任务逻辑 已废弃 *****
$find = Task::where('id', $order['extend']['task_id'])->find();
$extend=$find['extend'];
$extend['shareholder']['order_sn']=$order->sn;
@ -112,7 +113,7 @@ class PayNotifyLogic extends BaseLogic
// 更新充值订单状态
$order->transaction_id = $extra['transaction_id'];
$order->pay_status = PayEnum::ISPAID;
$order->pay_status = $extra['pay_status'];;
$order->pay_time = time();
$order->save();
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\common\logic;
use Symfony\Component\HttpClient\HttpClient;
class PayRequestLogic extends BaseLogic
{
public static function getPrePayId($param)
{
try {
$requestResponse = HttpClient::create()->request('POST', env('url.pay_prefix'). '/api/wechat_pay_service_merchant_pay/appPrePay', [
'body' => $param
]);
return json_decode($requestResponse->getContent(), true);
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -741,7 +741,16 @@ class TaskLogic extends BaseLogic
break;
// 政策补贴申请
case 'town_task_type_master_7':
self::masterTask7Settlement($taskSchedulePlan);
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
if($dayCount < $taskTemplateInfo['stage_day_one']) {
self::flushTaskTime($taskSchedulePlan);
return true;
}
// self::masterTask7Settlement($taskSchedulePlan);
break;
// 日常管理及其他临时任务
case 'town_task_type_master_8':
@ -854,32 +863,50 @@ class TaskLogic extends BaseLogic
}
}
// 判断收集任务,整体是否已完成
if ($dayCount == 60) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']);
$rate = bcdiv($purchaseSalesCount, $target, 2);
if ($rate >= 1) {
$rate = 1;
}
$totalMoney = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2),55, 2);
$taskInfo['money'] = bcmul($totalMoney, $rate, 2);
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool);
}
// 任务累计天数 大于 第一阶段 小于第一+第二阶段 判断交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount > $taskTemplateInfo['stage_day_one'] && $dayCount < $stageDayTwoCount) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = bcadd(count($purchaseSalesInfo['planting']), count($purchaseSalesInfo['supply']));
// 判断交易任务是否完成
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount);
self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $purchaseSalesCount);
}
// 任务累计天数 = 第一+第二阶段 判断信息收集和交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount == $stageDayTwoCount) {
$purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
$purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']);
if ($purchaseSalesCount >= $target) {
$taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2);
(new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool);
}
}
// if ($dayCount == $stageDayTwoCount) {
// $purchaseSalesInfo = $taskTemplateInfo['extend']['purchase_sales_info'];
// $purchaseSalesCount = count($purchaseSalesInfo['planting']) + count($purchaseSalesInfo['supply']);
// if ($purchaseSalesCount >= $target) {
// $taskInfo['money'] = bcmul(bcdiv($taskTemplateInfo['money_two'], 2, 2), $taskTemplateInfo['stage_day_two'], 2);
// (new TownShareProfit())->dealTaskSettlementMaster3($taskInfo, $townCompany, $taskSchedulePlan, $townTransactionPool);
// }
// }
// 任务累计天数 大于 第一+第二阶段 每日结算 判断交易任务是否完成,完成则结算,否则关闭任务
if ($dayCount >= $stageDayTwoCount) {
// 判断交易任务是否完成
self::judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target);
self::judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target);
}
}
private static function judgeMasterTask3Trade($taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target)
private static function judgeMasterTask3Trade($taskInfo, $taskTemplateInfo, $townCompany, $taskSchedulePlan, $purchaseSalesInfo, $townTransactionPool, $target)
{
// 查询收集到的用户在商城的交易金额(前置条件:信息收集中的手机号注册商城并交易)
$phoneList = [];
@ -894,12 +921,18 @@ class TaskLogic extends BaseLogic
'end_time' => strtotime(date('Y-m-d', time())) + 86399,
'phone' => implode(',', $phoneList)
];
$result = ShopRequestLogic::getUserTradeAmount($param); // todo 对接接口
$tradeAmount = $result['data']['procure_amount'];
$result = ShopRequestLogic::getUserTradeAmount($param);
if(isset($result['status']) && $result['status']== 400) {
$tradeAmount = 0;
}
if(isset($result['status']) && $result['status']== 200) {
$tradeAmount = $result['data']['trade_amount'];
}
$totalAmount = bcadd($tradeAmount, $townTransactionPool, 2); // 总的交易金额 = 当日交易额 + 累计交易池
// 目标金额 = 274 * 收集用户数
$targetTradeAmount = bcmul($target, 274, 2);
@ -937,8 +970,9 @@ class TaskLogic extends BaseLogic
'responsible_area' => $townCompany['responsible_area'],
'type' => 'street',
];
$result = ShopRequestLogic::getTownTradeAmount($param); // todo 对接接口
$tradeAmount = $result['data']['procure_amount'];
$result = ShopRequestLogic::getTownTradeAmount($param);
$tradeAmount = $result['data']['trade_amount'];
// 总交易额 交易池金额+商城交易额
$totalAmount = bcadd($townTransactionPool, $tradeAmount, 2);
@ -981,7 +1015,7 @@ class TaskLogic extends BaseLogic
// 任务累计天数第一个周期结算
if ($dayCount == $stageOneDayCount) {
$rate = bcdiv($liaisonManCount, $villageCount, 2);
if (bccomp($rate, 0.5, 2) == 1) {
if (bccomp($rate, 0.5, 2) == 1 || bccomp($rate, 0.5, 2) == 0) {
// 按个数结算
$taskInfo['money'] = bcmul($liaisonManCount, 120, 2);
(new TownShareProfit())->dealTaskSettlementMaster5($taskInfo, $townCompany, $taskSchedulePlan);
@ -1048,18 +1082,15 @@ class TaskLogic extends BaseLogic
* @param $taskSchedulePlan
* 政策补贴申请 单次
*/
private static function masterTask7Settlement($taskSchedulePlan)
public static function masterTask7Settlement($taskSchedulePlan)
{
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
if($dayCount < $taskTemplateInfo['stage_day_one']) {
self::flushTaskTime($taskSchedulePlan);
}
if ($dayCount == $taskTemplateInfo['stage_day_one']) {
if ($dayCount <= $taskTemplateInfo['stage_day_one']) {
// 审批通过后,任务状态会变更为已完成状态,审批是会根据凭证填入实际申请的政策补贴金额,根据该金额计算任务结算金额
if ($taskInfo['status'] == 3) {
$approve = Approve::where(['task_id' => $taskSchedulePlan['task_id']])->find();
@ -1164,29 +1195,42 @@ class TaskLogic extends BaseLogic
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true);
// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray();
$isDone = 1; // 任务是否完成标记
$isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记
foreach ($groupServiceCompanyList as $groupServiceCompany) {
// 查询小组服务公司是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
}
// 负责人任务类型id列表
$typeIds = [];
$townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
foreach ($townMasterTaskTypeList as $k => $item) {
if ($item == 'town_task_type_master_3') {
$typeIds[] = $k;
}
if ($item == 'town_task_type_master_4') {
$typeIds[] =$k;
}
// if ($item == 'town_task_type_master_5') {
// $typeIds[] = $k;
// }
if ($item == 'town_task_type_master_8') {
$typeIds[] = $k;
}
}
// 下属小组服务公司有任务安排,也完成了任务
// 查询 镇农科公司负责人是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
}
}
// 镇农科公司负责人有任务安排,也完成了任务
if ($isDone === 1 && $isTaskSchedule === 1) {
// 做任务结算,分润
(new TownShareProfit())->dealTaskSettlementMarketingDirector1($taskInfo, $townCompany, $taskSchedulePlan);
@ -1218,17 +1262,21 @@ class TaskLogic extends BaseLogic
// 当前任务进行天数 = 第一阶段天数 判定任务完成情况,结算
if ($dayCount == $templateInfo['stage_day_one']) {
// 请求商城接口,获取完成几家
$param['start_time'] = strtotime(date('Y-m-d', $templateInfo['cretate_time'])) + 86400;
$param['start_time'] = strtotime(date('Y-m-d', strtotime($templateInfo['create_time']))) + 86400;
$param['end_time'] = time();
$param['responsible_area'] = $townCompany['responsible_area'];
$param['type'] = 'street';
$param['type_id'] = 17;
$result = ShopRequestLogic::getSupplyChainMerchantCount($param);
if ($result['status'] != 200) {
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
return false;
$count = 0;
} else {
$count = $result['data']['count'];
}
$count = $result['data']['count'];
// 完成数小于3关闭任务不做结算
if ($count < 3){
@ -1260,6 +1308,7 @@ class TaskLogic extends BaseLogic
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
// 商城商户入驻申请id 与商户已关联
$shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray();
// 遍历农科公司区域下的商户,对每个商户进行判定
foreach ($shopMerchantSettleinLogList as $item) {
@ -1275,12 +1324,16 @@ class TaskLogic extends BaseLogic
'mer_intention_id' => $merIntentionId,
'type_id' => 17,
];
$result = ShopRequestLogic::getProductListing($param);
if ($result['status'] != 200) {
Log::info(['4.市场部长-供应链商户完成商品上架和库存更新任务-查询商城接口失败', json_encode($result)]);
return false;
$count = 0;
} else {
$count = $result['data']['count'];
}
$count = $result['data']['count'];
// 达到目标数 完成则结算
if ($count >= $templateInfo['extend']['target']){
// 结算金额 任务金额/目标数 * 天数
@ -1304,11 +1357,14 @@ class TaskLogic extends BaseLogic
'type_id' => 17
];
$result1 = ShopRequestLogic::getStockUpdate($param);
if ($result1['status'] != 200) {
Log::info(['4.市场部长-供应链商户完成库存更新任务-查询商城接口结果', json_encode($result)]);
return false;
$count = 0;
} else {
$count = $result1['data']['count'];
}
$count = $result1['data']['count'];
if ($count >= 1){
// 结算金额 任务金额/目标数 * 天数
$taskInfo['money'] = bcmul($templateInfo['stage_day_two'], bcdiv($templateInfo['money_two'], $templateInfo['extend']['target']));
@ -1336,12 +1392,14 @@ class TaskLogic extends BaseLogic
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
// 商城商户入驻申请id 与商户已关联
$shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray();
// 遍历农科公司区域下的商户,对每个商户进行判定
foreach ($shopMerchantSettleinLogList as $item) {
// 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算
$startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00
$endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00
$endTime = strtotime("+{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
// 任务判定
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo);
@ -1350,7 +1408,7 @@ class TaskLogic extends BaseLogic
// 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算
$startTime1 = $endTime; // 第一阶段 截止日 00:00:00
$stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']);
$endTime1 = strtotime("{$stageDayTwoCount} day", $startTime);
$endTime1 = strtotime("+{$stageDayTwoCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo);
}
@ -1358,7 +1416,7 @@ class TaskLogic extends BaseLogic
// 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算
$startTime2 = $endTime1; // 第二阶段 截止日 00:00:00
$stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']);
$endTime2 = strtotime("{$stageDayThreeCount} day", $startTime);
$endTime2 = strtotime("+{$stageDayThreeCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector4($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo);
}
@ -1403,10 +1461,10 @@ class TaskLogic extends BaseLogic
$result1 = ShopRequestLogic::getPurchaseAmount($param);
if ($result1['status'] != 200) {
Log::info(['4.市场部长-协助供应链商户采购任务-查询商城接口失败', json_encode($result1)]);
return false;
$result1['data']['procure_amount'] = 0;
}
if ($result1['data']['procure_amount'] > 0) {
$procureAmount = $result1['procure_amount'];
$procureAmount = $result1['data']['procure_amount'];
// 采购金额 实际完成率
$rate = self::countRate($procureAmount, $step);
@ -1434,12 +1492,6 @@ class TaskLogic extends BaseLogic
$taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate);
}
$taskInfo['money'] = $taskMoney;
$taskSchedulePlan = TaskSchedulingPlan::where(['id', $taskInfo['scheduling_plan_id']])
->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 41)
->where('is_pay',0)
->with(['template_info'])
->find();
Log::info(['5.市场部长-供应链商户完成采购任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]);
(new TownShareProfit())->dealTaskSettlementMarketingDirector4($taskInfo, $townCompany, $taskSchedulePlan);
}
@ -1494,12 +1546,13 @@ class TaskLogic extends BaseLogic
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
// 商城商户入驻申请id 与商户已关联
$shopMerchantSettleinLogList= ShopMerchantSettleinLog::where(['town_company_id'=>$townCompany['id']])->select()->toArray();
// 遍历农科公司区域下的商户,对每个商户进行判定
foreach ($shopMerchantSettleinLogList as $item) {
// 第一阶段 从入驻时间累计到第一阶段周期天数 为结算日期 只在截止日当天才结算
$startTime = strtotime(date('Y-m-d', strtotime($item['create_time']))); // 入驻当日 00:00:00
$endTime = strtotime("{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00
$endTime = strtotime("+{$templateInfo['stage_day_one']} day", $startTime); // $templateInfo['stage_day_one']天后的 00:00:00
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
// 任务判定
self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime, $endTime, 1, $townCompany, $taskInfo);
@ -1508,7 +1561,7 @@ class TaskLogic extends BaseLogic
// 第二阶段 从入驻时间累计到第二阶段周期天数 为结算日期 只在截止日当天才结算
$startTime1 = $endTime; // 第一阶段 截止日 00:00:00
$stageDayTwoCount = bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']);
$endTime1 = strtotime("{$stageDayTwoCount} day", $startTime);
$endTime1 = strtotime("+{$stageDayTwoCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime1, $endTime1, 2, $townCompany, $taskInfo);
}
@ -1516,7 +1569,7 @@ class TaskLogic extends BaseLogic
// 第三阶段 从入驻时间累计到第三阶段周期天数 为结算日期 只在截止日当天才结算
$startTime2 = $endTime1; // 第二阶段 截止日 00:00:00
$stageDayThreeCount = bcadd(bcadd($templateInfo['stage_day_one'], $templateInfo['stage_day_two']), $templateInfo['stage_day_three']);
$endTime2 = strtotime("{$stageDayThreeCount} day", $startTime);
$endTime2 = strtotime("+{$stageDayThreeCount} day", $startTime);
if (date('Y-m-d', $endTime) == date('Y-m-d', time())){
self::judgeTaskMarketingDirector5($templateInfo, $item, $taskSchedulePlan, $startTime2, $endTime2, 3, $townCompany, $taskInfo);
}
@ -1559,11 +1612,13 @@ class TaskLogic extends BaseLogic
'type'=>300
];
$result1 = ShopRequestLogic::getTradeAmount($param);
if ($result1['status'] != 200) {
if ($result1['status'] == 200) {
$tradeAmount = $result1['data']['procure_amount'];
} else {
Log::info(['4.市场部长-协助供应链商户销售任务-查询商城接口失败', json_encode($result1)]);
return false;
$tradeAmount = 0;
}
$tradeAmount = $result1['data']['procure_amount'];
if ($tradeAmount > 0) {
// 采购金额 实际完成率
@ -1575,6 +1630,7 @@ class TaskLogic extends BaseLogic
$taskMoney = 0;
// 全额完成可获得的总金额
$totalMoney = bcmul(30, bcdiv($templateInfo['money_three'], $templateInfo['extend']['target'], 2), 2);
// 已完成 计算结算金额
if ($step == 1) {
$totalMoney = bcmul($templateInfo['stage_day_one'], bcdiv($templateInfo['money'], $templateInfo['extend']['target'], 2), 2);
@ -1592,6 +1648,7 @@ class TaskLogic extends BaseLogic
// 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例
$taskMoney= self::countTaskMarketingDirector4TaskMoney($totalMoney, $rate);
}
$taskInfo['money'] = $taskMoney;
Log::info(['5.市场部长-供应链商户完成商品销售任务-$taskSchedulePlan', json_encode($taskSchedulePlan)]);
(new TownShareProfit())->dealTaskSettlementMarketingDirector5($taskInfo, $townCompany, $taskSchedulePlan);
@ -1666,8 +1723,12 @@ class TaskLogic extends BaseLogic
'type_id' => 10
];
$result = ShopRequestLogic::getGeneralMerchantCount($param);
Log::error('查询供应链商户统计接口失败'.ShopRequestLogic::getError());
$count = $result['data']['count'];
if ($result['status'] == 200) {
$count = $result['data']['count'];
} else {
$count = 0;
}
if ($count >= $target) {
$taskMoney = $totalMoney;
return $taskMoney;
@ -1745,10 +1806,10 @@ class TaskLogic extends BaseLogic
// 任务累计天数==第一阶段 查询第一阶段期间入驻的商户是否完成商品上架任务
if ($dayCount == $stageDayOne) {
$taskIsDone = self::judgeTaskMarketingDirector7(-$townCompany);
$taskIsDone = self::judgeTaskMarketingDirector7($townCompany);
// 结算分润
if($taskIsDone) {
$taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2);
$taskInfo['money'] = bcmul($stageDayOne, $templateInfo['money'], 2);
(new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan);
} else {
(new Task())->closeTask($taskSchedulePlan['task_id']);
@ -1766,7 +1827,7 @@ class TaskLogic extends BaseLogic
$taskIsDone = self::judgeTaskMarketingDirector7($townCompany);
// 结算分润
if($taskIsDone) {
$taskInfo['money'] = bcmul($taskIsDone, $templateInfo['money'], 2);
$taskInfo['money'] = bcmul($templateInfo['stage_day_two'], $templateInfo['money'], 2);
(new TownShareProfit())->dealTaskSettlementMarketingDirector7($taskInfo,$townCompany, $taskSchedulePlan);
} else {
(new Task())->closeTask($taskSchedulePlan['task_id']);
@ -2071,7 +2132,7 @@ class TaskLogic extends BaseLogic
return 0;
}
$taskMoney = 0;
if ($tradeAmount >= 100000) {
if ($tradeAmount >= $targetProcureAmount) {
$taskMoney = $totalMoney;
} else {
// 计算结算金额 周期天数*(money/目标数)*实际完成率*对应发放比例
@ -2229,27 +2290,41 @@ class TaskLogic extends BaseLogic
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskInfo = Task::where(['id' => $taskSchedulePlan['task_id']])->find();
$townCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$groupServiceCompanyList = Db::query("select * from la_company where company_type=:company_type and FIND_IN_SET(street,:responsible_area)", ['company_type' => 18,'responsible_area'=>$townCompany['responsible_area']], true);
// $groupServiceCompanyList = Company::where(['street' => $townCompany['street'], 'company_type' => 18])->select()->toArray();
$isDone = 1; // 任务是否完成标记
$isTaskSchedule = 0; // 下属小组服务公司是否有每日任务安排标记
foreach ($groupServiceCompanyList as $groupServiceCompany) {
// 查询小组服务公司是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id' => $groupServiceCompany['id']])->whereIn('type', [31, 32, 33])->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询小组服务公司的循环任务有没有全部做完 任意有一个任务没有做完,则判定为该小组服务公司没有完成每日任务,即协助总负责人开展工作任务也认定失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
// 负责人 每日任务类型id列表
$typeIds = [];
$townMasterTaskTypeList = DictData::where(['type_value' => 'town_task_type_master', 'status' => 1])->column('value', 'id');
foreach ($townMasterTaskTypeList as $k=>$item) {
if ($item == 'town_task_type_master_3') {
$typeIds[] = $k;
}
if ($item == 'town_task_type_master_4') {
$typeIds[] = $k;
}
// if ($item == 'town_task_type_master_5') {
// $typeIds[] = $k;
// }
if ($item == 'town_task_type_master_8') {
$typeIds[] = $k;
}
}
// 查询 镇农科公司负责人是否有对应的每日任务安排
$templateList = TaskTemplate::where(['company_id'=>$townCompany['id']])->whereIn('type', $typeIds)->select()->toArray();
// 未做任务安排的小组服务公司不在判定范围内,跳出本次循环
if(count($templateList) === 3) {
$isTaskSchedule = 1;
// 查询负责人的循环任务有没有全部做完 任意有一个任务没有做完,则判定为 协助总负责人开展工作任务 失败
foreach ($templateList as $template) {
$task = Task::where(['template_id' => $template['id'], 'status' => 3])->find();
if (empty($task)) {
$isDone = 0;
break;
}
}
}
// 下属小组服务公司有任务安排,也完成了任务
if ($isDone === 1 && $isTaskSchedule === 1) {
// 做任务结算,分润
@ -2537,12 +2612,13 @@ class TaskLogic extends BaseLogic
if ($tempTask) {
$plan = TaskSchedulingPlan::where(['id'=>$tempTask['scheduling_plan_id']])->find();
if ($plan['is_pay'] == 1) {
$extend = json_decode($tempTask['extend'], true);
$extend = $tempTask['extend'];
$targetAmount += $extend['transaction']['arr']['day_money'];
$townTotalTradeAmount += $extend['transaction']['arr']['total_price'];
}
}
}
// 完成条件: 查镇所属小组服务公司当日实际完成金额总和+镇农科公司的资金池 > 查镇所属小组服务公司当日任务目标金额总和
if($targetAmount != 0 && bcadd($townTransactionPool, $townTotalTradeAmount, 2) >= $targetAmount) {
// 将余下金额放入镇交易池
@ -2565,12 +2641,10 @@ class TaskLogic extends BaseLogic
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$taskDayCount = $taskTemplateInfo['day_count']; // 任务累计进行天数
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
$stageDayOneAccumulative = $taskTemplateInfo['stage_day_one']; // 第一阶段累计天数
$stageDayTwoAccumulative = intval(bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two'])); // 第二阶段累计天数 第一+第二
$townCompany = Company::where('id', $taskTemplateInfo['company_id'])->find(); // 镇农科公司
$villageCompanyList = Company::where(['street' => $townCompany['street'], 'company_type'=> 17])->select()->toArray(); // 村管理公司
dd($taskDayCount, $stageDayTwoAccumulative);
// 当前任务进行天数 <= 第一+第二阶段天数 判定任务是否完成 结算 分润
if($taskDayCount <= $stageDayTwoAccumulative) {
// 小组服务公司总数
@ -2974,12 +3048,11 @@ class TaskLogic extends BaseLogic
Log::info(['镇农科公司定时任务结算执行-'.$taskSchedulePlan['template_info']['title']]);
$taskTemplateInfo = $taskSchedulePlan['template_info'];
$dayCount = $taskTemplateInfo['day_count'];
$target = $taskTemplateInfo['extend']['target'];
$stageDayOne = $taskTemplateInfo['stage_day_one'];
$stageDayTwoCount = bcadd($taskTemplateInfo['stage_day_one'], $taskTemplateInfo['stage_day_two']);
$stageDayThreeCount = bcadd($stageDayTwoCount, $taskTemplateInfo['stage_day_three']);
$villageCompany = Company::where(['id' => $taskTemplateInfo['company_id']])->find();
$task = Task::where('id', $taskSchedulePlan['task_id'])->find();
// 任务累计天数 < stage1 关闭任务
if ($dayCount < $stageDayOne) {
@ -3045,10 +3118,12 @@ class TaskLogic extends BaseLogic
$param = [
'start_time' => $startTime,
'end_time' => $endTime,
'village' => $villageCompany['village']
'village' => $villageCompany['village'],
];
$result = ShopRequestLogic::getPlantingAndBreedingMerchantTradeAmount($param); // todo 商城接口那边需要确定种养殖基地是何种类型的商户
$tradeAmount = $result['data']['procure_amount'];
$tradeAmount = $result['data']['trade_amount'];
// 交易池
$transactionPool = $taskSchedulePlan['template_info']['transaction_pool'];
$totalTradeAmount = bcadd($transactionPool, $tradeAmount, 2);

View File

@ -142,7 +142,7 @@ class TaskTemplateLogic extends BaseLogic
} else {
$taskScheduleAmount = 200;
}
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type,money,money_two,money_three')->find();
$find=TaskTemplate::where('task_scheduling', $params['task_scheduling'])->where('company_id',$params['company_id'])->where('type',$params['type'])->field('id,types,type,money,money_two,money_three,extend')->find();
if($find && $find['id']!=$params['id']&&$params['type']==$find['type']){
self::setError('已经有同一种任务类型了');
return false;
@ -193,7 +193,7 @@ class TaskTemplateLogic extends BaseLogic
'types' => $params['types'],
'status' => $params['status'],
'content' => $params['content'],
'extend'=>json_encode($params['extend']),
'extend'=>json_encode(array_merge($find['extend'],$params['extend'])),
'stage_day_one' => $params['stage_day_one']??0,
'proportion_one' => $params['proportion_one']??0,
'stage_day_two' => $params['stage_day_two']??0,

View File

@ -354,43 +354,14 @@ class WeChatPayService extends BasePayService
/**
* @notes 支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @author 段誉
* @date 2023/2/28 14:20
*/
public function notify()
public function notify($param=[])
{
$server = $this->app->getServer();
// 支付通知
$server->handlePaid(function (Message $message) {
$data = ['trade_state' => $message['trade_state'] ?? '', 'out_trade_no' => $message['out_trade_no'] ?? '', 'transaction_id' => $message['transaction_id'] ?? '', 'attach' => $message['attach'] ?? ''];
Log::info('wechat pay notify: ' . var_export($data, true));
if ($message['trade_state'] === 'SUCCESS') {
$extra['transaction_id'] = $message['transaction_id'];
$attach = $message['attach'];
$message['out_trade_no'] = mb_substr($message['out_trade_no'], 0, 18);
switch ($attach) {
case 'recharge':
$order = RechargeOrder::where(['sn' => $message['out_trade_no']])->findOrEmpty();
if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) {
return true;
}
PayNotifyLogic::handle('recharge', $message['out_trade_no'], $extra);
break;
}
}
return true;
});
// 退款通知
$server->handleRefunded(function (Message $message) {
return true;
});
return $server->serve();
Log::info(['支付回调', $param]);
$extra['transaction_id'] = $param['transaction_id'];
$extra['pay_status'] = $param['pay_status'];
PayNotifyLogic::handle('recharge', $param['out_trade_no'], $extra);
return true;
}
public function configForPayment($prepayId, $appId)

View File

@ -29,11 +29,14 @@ class AccountLogController extends BaseLikeAdminController
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'type','company_id']);
$params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'user_info', 'type', 'change_type', 'company_id']);
$where = [];
if (isset($params['type']) && $params['type'] == 'um') {
$where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()];
}
if (!empty($params['change_type'])) {
$where[] = ['change_type', '=', $params['change_type']];
}
if (!empty($params['company_id'])) {
$where[] = ['company_id', '=', $params['company_id']];
}

View File

@ -3,9 +3,11 @@
namespace app\middleapi\controller;
use app\adminapi\logic\auth\AdminLogic;
use app\adminapi\logic\user\UserLogic;
use app\adminapi\validate\CompanyValidate;
use app\api\controller\JunziqianController;
use app\common\controller\BaseLikeAdminController;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\CompanyLogic;
use app\common\logic\contract\ContractLogic;
use app\common\logic\RedisLogic;
@ -17,6 +19,7 @@
use app\common\model\task_scheduling\TaskScheduling;
use app\common\model\user\User;
use app\common\model\CompanyDepositVoucher;
use Exception;
use think\facade\Db;
use think\facade\Log;
use think\response\Json;
@ -330,7 +333,7 @@
return $this->success('success', array_unique($data));
}
public function getDepositRechargeTransferVoucherList()
public function getDepositRechargeTransferVoucherList(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
@ -358,7 +361,7 @@
return $this->success('请求成功',$result);
}
public function depositRechargeTransferVoucher()
public function depositRechargeTransferVoucher(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
@ -416,7 +419,7 @@
}
public function getPartyA()
public function getPartyA(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
@ -431,4 +434,51 @@
}
return $this->success('成功', $re);
}
//获取公司成员
public function companyUserLists(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params = $this->request->post(['company_id','page_no','page_size']);
if(empty($params['company_id'])){
return $this->fail('参数错误');
}
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
$field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract";
$lists = User::with(['company'])
->where('company_id',$params['company_id'])
->page($pageNo, $pageSize)
->field($field)
->order('id desc')
->select()
->toArray();
foreach ($lists as &$item) {
$item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
}
$count = User::where('company_id',$params['company_id'])->count();
$result = [
'lists' => $lists,
'count' => $count,
'page_no' => $pageNo,
'page_size' => $pageSize
];
return $this->success('请求成功',$result);
}
//获取公司成员详情
public function companyUserDetail(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params = $this->request->post(['user_id']);
if(empty($params['user_id'])){
return $this->fail('参数错误');
}
$detail = UserLogic::detail($params['user_id']);
return $this->success('', $detail);
}
}

View File

@ -44,7 +44,8 @@
"jpush/jpush": "^3.6",
"topthink/think-filesystem": "^2.0",
"alibabacloud/live": "^1.8",
"alibabacloud/live-20161101": "1.1.1"
"alibabacloud/live-20161101": "1.1.1",
"ext-bcmath": "*"
},
"require-dev": {
"symfony/var-dumper": "^4.2",