增加:小酒馆补差实际支付金额 某个商户总额达到指定金额时,自动成为该商户的共创股东
This commit is contained in:
parent
a34b935b82
commit
fa6f42abe4
|
|
@ -200,6 +200,8 @@ class ExchangeQuotaRepository extends BaseRepository{
|
||||||
'quota_integral_diff_rate',
|
'quota_integral_diff_rate',
|
||||||
'quota_integral_give_money',
|
'quota_integral_give_money',
|
||||||
'quota_integral_give_card',
|
'quota_integral_give_card',
|
||||||
|
'quota_integral_shareholder_money',
|
||||||
|
'quota_integral_shareholder_level_id'
|
||||||
]);
|
]);
|
||||||
// 信息处理
|
// 信息处理
|
||||||
$config['quota_integral_switch'] = (int)$config['quota_integral_switch'];
|
$config['quota_integral_switch'] = (int)$config['quota_integral_switch'];
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,8 @@ class ExchangeQuota extends BaseController{
|
||||||
['quota_integral_diff_rate',0],
|
['quota_integral_diff_rate',0],
|
||||||
['quota_integral_give_money',0],
|
['quota_integral_give_money',0],
|
||||||
['quota_integral_give_card',0],
|
['quota_integral_give_card',0],
|
||||||
|
['quota_integral_shareholder_money',0],
|
||||||
|
['quota_integral_shareholder_level_id',0],
|
||||||
]);
|
]);
|
||||||
// 保存信息
|
// 保存信息
|
||||||
$cid = app()->make(ConfigClassifyRepository::class)->getConfigClassifyKeyById('quota_config', '额度与积分配置');
|
$cid = app()->make(ConfigClassifyRepository::class)->getConfigClassifyKeyById('quota_config', '额度与积分配置');
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,18 @@ use app\common\model\user\User;
|
||||||
use app\common\model\user\UserInviteCode;
|
use app\common\model\user\UserInviteCode;
|
||||||
use app\common\repositories\marketing\activity\RecordRepository;
|
use app\common\repositories\marketing\activity\RecordRepository;
|
||||||
use app\common\repositories\marketing\AgentBrokerageRepository;
|
use app\common\repositories\marketing\AgentBrokerageRepository;
|
||||||
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use app\common\repositories\system\groupData\GroupDataRepository;
|
||||||
use app\common\repositories\system\merchant\MerchantQuotaRecordRepository;
|
use app\common\repositories\system\merchant\MerchantQuotaRecordRepository;
|
||||||
use app\common\repositories\system\merchant\MerchantRepository;
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
|
use app\common\repositories\system\merchant\MerchantShareholderLevelRepository;
|
||||||
use app\common\repositories\system\merchant\MerchantShareholderRepository;
|
use app\common\repositories\system\merchant\MerchantShareholderRepository;
|
||||||
use app\common\repositories\user\ExchangePickupPointRepository;
|
use app\common\repositories\user\ExchangePickupPointRepository;
|
||||||
use app\common\repositories\user\ExchangeQuotaRepository;
|
use app\common\repositories\user\ExchangeQuotaRepository;
|
||||||
use app\common\repositories\user\UserInviteCodeRepository;
|
use app\common\repositories\user\UserInviteCodeRepository;
|
||||||
|
use app\common\repositories\user\UserOrderRepository;
|
||||||
use crmeb\jobs\UserBrokerageLevelJob;
|
use crmeb\jobs\UserBrokerageLevelJob;
|
||||||
|
use think\exception\ValidateException;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use think\facade\Queue;
|
use think\facade\Queue;
|
||||||
|
|
||||||
|
|
@ -49,7 +54,14 @@ class OrderPaySuccessEvent{
|
||||||
// 进货订单
|
// 进货订单
|
||||||
case 35:break;
|
case 35:break;
|
||||||
// 酒道馆和小酒馆兑换订单
|
// 酒道馆和小酒馆兑换订单
|
||||||
case 36:break;
|
case 36:
|
||||||
|
// 补差实际支付总金额达标 - 赠送会员卡
|
||||||
|
$this->giveVip($groupOrder);
|
||||||
|
// 某个商户补差实际支付金额达标 - 自动成为该商户共创股东
|
||||||
|
$this->autoBecomeShareholder($groupOrder);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
// 共创股东加入
|
// 共创股东加入
|
||||||
case 37:
|
case 37:
|
||||||
foreach($groupOrder->orderList as $orderInfo){
|
foreach($groupOrder->orderList as $orderInfo){
|
||||||
|
|
@ -80,28 +92,29 @@ class OrderPaySuccessEvent{
|
||||||
'group_order_id' => $groupOrder->group_order_id,
|
'group_order_id' => $groupOrder->group_order_id,
|
||||||
'msg' => $e->getMessage()
|
'msg' => $e->getMessage()
|
||||||
];
|
];
|
||||||
if($groupOrder->activity_type == 30){
|
$title = '支付成功';
|
||||||
|
// 根据订单类型进行对应的处理
|
||||||
|
switch((int)$groupOrder->activity_type){
|
||||||
// 在线支付订单
|
// 在线支付订单
|
||||||
Log::info('支付成功 - 赠送酒水卡积分 - 错误: '.var_export($data,1));
|
case 30:$title = '支付成功 - 在线支付订单';break;
|
||||||
}
|
// 兑换商品补差价处理
|
||||||
else if($groupOrder->activity_type == 31){
|
case 31:$title = '支付成功 - 兑换商品补差价处理';break;
|
||||||
Log::info('支付成功 - 兑换商品补差价处理 - 错误: '.var_export($data,1));
|
// 代理入驻支付
|
||||||
}
|
case 32:$title = '支付成功 - 代理入驻';break;
|
||||||
else if($groupOrder->activity_type == 32){
|
// 加入活动支付成功
|
||||||
Log::info('支付成功 - 邀请代理人员奖励及免审核 - 错误: '.var_export($data,1));
|
case 33:$title = '支付成功 - 加入活动';break;
|
||||||
}
|
// 邀请码激活
|
||||||
else if($groupOrder->activity_type == 33){
|
case 34:$title = '支付成功 - 邀请码激活';break;
|
||||||
Log::info('支付成功 - 加入活动支付成功 - 错误: '.var_export($data,1));
|
// 进货订单
|
||||||
}
|
case 35:$title = '支付成功 - 进货订单';break;
|
||||||
else if($groupOrder->activity_type == 34){
|
// 酒道馆和小酒馆兑换订单
|
||||||
Log::info('支付成功 - 邀请码激活 - 错误: '.var_export($data,1));
|
case 36:$title = '支付成功 - 酒道馆和小酒馆兑换订单';break;
|
||||||
}
|
// 共创股东加入
|
||||||
else if($groupOrder->activity_type == 35){
|
case 37:$title = '支付成功 - 共创股东加入';break;
|
||||||
Log::info('支付成功 - 进货订单 - 错误: '.var_export($data,1));
|
// 配送商缴费支付成功
|
||||||
}
|
case 38:$title = '支付成功 - 配送商缴费支付成功';break;
|
||||||
else{
|
|
||||||
Log::info('支付成功 - 赠送酒卡额度 - 错误: '.var_export($data,1));
|
|
||||||
}
|
}
|
||||||
|
Log::info($title . ' - 错误: '.var_export($data,1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 支付成功 - 赠送酒卡额度
|
// 支付成功 - 赠送酒卡额度
|
||||||
|
|
@ -332,15 +345,122 @@ class OrderPaySuccessEvent{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// 小酒馆补差实际支付金额 补差实际支付总金额达标 - 赠送会员卡
|
||||||
|
public function giveVip($groupOrder){
|
||||||
|
// 订单状态(0:待发货;1:待收货;2:待评价;3:已完成; 9: 拼团中 10: 待付尾款 11:尾款超时未付 -1:已退款)
|
||||||
|
try{
|
||||||
|
// 设置信息获取
|
||||||
|
$config = app()->make(ExchangeQuotaRepository::class)->getConfig();
|
||||||
|
$targetMoney = (float)$config['quota_integral_give_money'];
|
||||||
|
if($targetMoney <= 0) throw new ValidateException('未设置目标金额!');
|
||||||
|
// 获取总有效金额 查看是否达标
|
||||||
|
$totalMoney = app()->make(StoreOrderRepository::class)
|
||||||
|
->getSearch([
|
||||||
|
'uid' => $groupOrder->uid,
|
||||||
|
'activity_type' => 36,
|
||||||
|
'paid' => 1
|
||||||
|
])
|
||||||
|
->whereIn('status', [0,1,2,3])
|
||||||
|
->sum('quota_integral_diff_money');
|
||||||
|
if($targetMoney > $totalMoney) throw new ValidateException("未达标!要求:{$targetMoney};当前:{$totalMoney}");
|
||||||
|
// 判断:当前用户是否已经领取
|
||||||
|
$isGet = app()->make(UserOrderRepository::class)->getSearch(['source'=>3])->value('order_id');
|
||||||
|
if($isGet > 0) throw new ValidateException("当前用户已发放!");
|
||||||
|
// 判断:是否符合会员卡开通条件
|
||||||
|
$user = User::where('uid', $groupOrder->uid)->findOrEmpty();
|
||||||
|
$vipInfo = app()->make(GroupDataRepository::class)->getWhere(['group_data_id' => $config['quota_integral_give_card'], 'status' => 1]);
|
||||||
|
if (!$vipInfo) throw new ValidateException('会员卡不存在!');
|
||||||
|
if ($user->is_svip == 3) throw new ValidateException('会员已经是终身会员!');
|
||||||
|
if ($user->is_svip !== -1 && $vipInfo['value']['svip_type'] == 1) throw new ValidateException('会员已开通该类型会员!');
|
||||||
|
// 模拟下单
|
||||||
|
$params['pay_type'] = 'free';
|
||||||
|
$params['return_url'] = '';
|
||||||
|
$params['is_app'] = request()->isApp();
|
||||||
|
$params['source'] = 3;
|
||||||
|
app()->make(UserOrderRepository::class)->add($vipInfo, $user, $params);
|
||||||
|
}catch(\Exception $e){
|
||||||
|
$data = [
|
||||||
|
'uid' => $groupOrder->uid,
|
||||||
|
'group_order_id' => $groupOrder->group_order_id,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
];
|
||||||
|
Log::info('小酒馆补差实际支付金额达标赠送会员卡 - 错误: '.var_export($data,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 小酒馆补差实际支付金额 某个商户补差实际支付金额达标 - 自动成为该商户共创股东
|
||||||
|
public function autoBecomeShareholder($groupOrder){
|
||||||
|
try{
|
||||||
|
// 设置信息获取
|
||||||
|
$config = app()->make(ExchangeQuotaRepository::class)->getConfig();
|
||||||
|
$targetMoney = (float)$config['quota_integral_shareholder_money'];
|
||||||
|
if($targetMoney <= 0) throw new ValidateException('未设置目标金额!');
|
||||||
|
// 获取共创股东等级信息
|
||||||
|
$levelInfo = app()->make(MerchantShareholderLevelRepository::class)
|
||||||
|
->getSearchModel(['id' => $config['quota_integral_shareholder_level_id']])
|
||||||
|
->findOrEmpty()
|
||||||
|
->toArray();
|
||||||
|
// 循环处理每个订单
|
||||||
|
if($levelInfo){
|
||||||
|
foreach($groupOrder->orderList as $orderInfo){
|
||||||
|
$totalMoney = app()->make(StoreOrderRepository::class)
|
||||||
|
->getSearch([
|
||||||
|
'uid' => $orderInfo->uid,
|
||||||
|
'activity_type' => 36,
|
||||||
|
'paid' => 1,
|
||||||
|
'mer_id' => $orderInfo->mer_id,
|
||||||
|
])
|
||||||
|
->whereIn('status', [0,1,2,3])
|
||||||
|
->sum('quota_integral_diff_money');
|
||||||
|
// 未达标
|
||||||
|
if($targetMoney > $totalMoney) continue;
|
||||||
|
// 是否已经是当前商户的共创股东
|
||||||
|
$isExistence = (int)app()->make(MerchantShareholderRepository::class)->getSearchModel([
|
||||||
|
'mer_id' => $orderInfo->mer_id,
|
||||||
|
'uid' => $orderInfo->uid,
|
||||||
|
])->value('id');
|
||||||
|
if($isExistence > 0) continue;
|
||||||
|
// 判断:当前商户的本等级共创股东是否已经达到上限
|
||||||
|
if($levelInfo['mer_quota'] > 0){
|
||||||
|
$quotaUsed = (int)app()->make(MerchantShareholderRepository::class)
|
||||||
|
->getSearchModel(['mer_id' => $orderInfo->mer_id,'level_id' => $levelInfo['id']])
|
||||||
|
->count();
|
||||||
|
// 等级名额限制 小于等于 已邀请名额;禁止加入
|
||||||
|
if($levelInfo['mer_quota'] <= $quotaUsed) continue;
|
||||||
|
}
|
||||||
|
// 自动成为共创股东
|
||||||
|
$merchantShareholderId = app()->make(MerchantShareholderRepository::class)->createJoinInfo([
|
||||||
|
'uid' => $orderInfo->uid,
|
||||||
|
'mer_id' => $orderInfo->mer_id,
|
||||||
|
'level_id' => $levelInfo['id'],
|
||||||
|
]);
|
||||||
|
app()->make(MerchantShareholderRepository::class)->joinSuccess($merchantShareholderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(\Exception $e){
|
||||||
|
$data = [
|
||||||
|
'uid' => $groupOrder->uid,
|
||||||
|
'group_order_id' => $groupOrder->group_order_id,
|
||||||
|
'msg' => $e->getMessage()
|
||||||
|
];
|
||||||
|
Log::info('小酒馆补差实际支付金额达标成为共创股东 - 错误: '.var_export($data,1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common: 赠送惠民积分处理
|
* Common: 赠送惠民积分处理
|
||||||
* Author: wu-hui
|
* Author: wu-hui
|
||||||
* Time: 2024/07/01 14:35
|
* Time: 2024/07/01 14:35
|
||||||
* @param $uid
|
* @param $orderInfo
|
||||||
* @param $merId
|
* @param $remark
|
||||||
* @param $orderInfo
|
* @param $source
|
||||||
* @param $remark
|
* @param $payPrice
|
||||||
* @param $source
|
* @param int $productId
|
||||||
|
* @param int $orderProductId
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function giveQuotaIntegral($orderInfo, $remark, $source, $payPrice, $productId = 0, $orderProductId = 0){
|
private function giveQuotaIntegral($orderInfo, $remark, $source, $payPrice, $productId = 0, $orderProductId = 0){
|
||||||
|
|
@ -377,10 +497,4 @@ class OrderPaySuccessEvent{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue