This commit is contained in:
yaooo 2023-10-16 19:30:19 +08:00
commit a33f154b31
7 changed files with 1423 additions and 42 deletions

View File

@ -33,7 +33,7 @@ class ApproveController extends BaseApiController
if (!$approve) {
throw new Exception('数据不存在');
}
ApproveLogic::audit($approve, $params);
ApproveLogic::audit($approve, $params, $this->userInfo);
return $this->success('操作成功');
} catch (Exception $exception) {
return $this->fail(ApproveLogic::getError() ?? $exception->getMessage());

View File

@ -0,0 +1,20 @@
<?php
namespace app\api\controller;
use app\common\logic\task\TaskLogic;
use app\common\model\Company;
use app\common\model\dict\DictData;
use app\common\model\task\Task;
use app\common\model\task_template\TaskTemplate;
use think\Exception;
use think\facade\Db;
use think\facade\Log;
/**
* 商城主动调用接口类
*/
class ShopCallController extends BaseApiController
{
}

View File

@ -0,0 +1,192 @@
<?php
namespace app\common\logic;
use Symfony\Component\HttpClient\HttpClient;
use think\Exception;
class ShopRequestLogic extends BaseLogic
{
public static $shopUrlPrefix;
public function __construct()
{
self::$shopUrlPrefix = env('url.shop_prefix');
parent::__construct();
}
/**
* 查询时间范围内,某一农科公司下的 供应链商户入驻统计
*/
public static function getSupplyChainMerchantCount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询供应链商户入驻5天内是否完成商品上架
*/
public static function getProductListing($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 供应链商户入驻20天后是否完成库存更新
*/
public static function getStockUpdate($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询商城商品列表 供任务,模板中指定商品
*/
public static function getProductList($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询供应链商户指定商品采购金额
*/
public static function getPurchaseAmount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询供应链商户指定商品销售金额
*/
public static function getTradeAmount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询镇农科公司区域 指定时间范围内入驻的一般商户数量
*/
public static function getGeneralMerchantCount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询一般商户入驻5天内是否完成商品上架
*/
public static function getGeneralMerchantProductListing($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询一般商户入驻5天内是否完成库存更新
*/
public static function getGeneralMerchantStockUpdate($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询一般商户指定商品采购金额
*/
public static function getGeneralMerchantPurchaseAmount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* 查询一般商户指定商品销售金额
*/
public static function getGeneralMerchantTradeAmount($param)
{
try {
$requestResponse = HttpClient::create()->request('GET', self::$shopUrlPrefix . '', [
'query' => $param
]);
return $requestResponse->getContent();
} catch (Exception $e) {
self::setError($e->getMessage());
return false;
}
}
}

View File

@ -4,6 +4,7 @@ namespace app\common\logic\approve;
use app\common\logic\BaseLogic;
use app\common\model\Approve;
use app\common\model\ShopMerchantSettleinLog;
use Symfony\Component\HttpClient\HttpClient;
use think\facade\Db;
use think\facade\Log;
@ -11,7 +12,7 @@ use think\facade\Log;
class ApproveLogic extends BaseLogic
{
public static function audit($approve, $params)
public static function audit($approve, $params, $userInfo)
{
// 拒绝通过
if ($params['check_status'] == 3) {
@ -22,7 +23,7 @@ class ApproveLogic extends BaseLogic
}
// 修改任务完成状态
if ($params['check_status'] == 2) {
self::pass($approve);
self::pass($approve,$userInfo);
}
// 回调商城,通知审核状态
@ -32,10 +33,20 @@ class ApproveLogic extends BaseLogic
}
}
private static function pass(Approve $approve)
private static function pass(Approve $approve, $userInfo)
{
Db::startTrans();
$approve->check_status = 2;
$approve->save();
// 记录商户入驻时间,镇农科公司市场部长任务会使用到
$shopMerchantInfo = json_decode($approve['extend'], true);
$data = [
'town_company_id' => $userInfo['company_id'],
'mer_intention_id' => $shopMerchantInfo['mer_intention_id'],
'create_time' => time()
];
ShopMerchantSettleinLog::create($data);
Db::commit();
}
private static function refuse(Approve $approve, $params)

View File

@ -156,9 +156,23 @@ class TownShareProfit
$masterMoney = bcdiv($taskInfo['money'], 2, 2);
$remark = '来自任务【' . $taskSchedulePlan['template_info']['title'] . '】,';
//负责人收益 todo
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 1) {
}
//市场部长收益
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 2) {
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 16])->find();
Log::info([$taskSchedulePlan['template_info']['title'].'结算-市场部长用户信息', $serviceManagerUser]);
}
//服务部长收益 任务金额的50%为服务部长的收益
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 14])->find();
Log::info([$taskSchedulePlan['template_info']['title'].'结算-服务部长用户信息', $serviceManagerUser]);
if ($taskSchedulePlan['template_info']['extend']['task_role'] == 3) {
$serviceManagerUser = User::where(['company_id' => $company['id'], 'group_id' => 14])->find();
Log::info([$taskSchedulePlan['template_info']['title'].'结算-服务部长用户信息', $serviceManagerUser]);
}
// 用户收益变动
$arr = [$serviceManagerUser['id'], AccountLogEnum::UM_INC_TASK, AccountLogEnum::INC, $masterMoney, $taskSchedulePlan['sn'], $remark.'任务结算获得收益' . $masterMoney . '元', ['company_id' => $company['id'], 'proportion' => $proportion], 1];
$this->master($arr);
@ -213,4 +227,169 @@ class TownShareProfit
{
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
}
/**
*
*/
public function dealTaskSettlementMarketingDirector1($taskInfo, $townCompany, $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector2(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector3(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector4(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector5(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector6(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector7(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getFile(). $e->getLine(). $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector8(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
public function dealTaskSettlementMarketingDirector9(Task $taskInfo, Company $townCompany, TaskSchedulingPlan $taskSchedulePlan)
{
try {
Db::startTrans();
$this->shareProfit($taskInfo, $townCompany, $taskSchedulePlan);
// 更改结算状态
(new TaskSchedulingPlan())->settlement($taskSchedulePlan['id']);
// 更改任务状态
Task::where(['id' => $taskSchedulePlan['task_id']])->update(['status' => 3]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
Log::error($taskSchedulePlan['template_info']['title'].'-任务结算失败:' . $e->getMessage());
return false;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
<?php
namespace app\common\model;
class ShopMerchantSettleinLog extends BaseModel
{
protected $name = 'shop_merchant_settle_log';
}