添加:活动参加及支付流程及赠送流程
This commit is contained in:
parent
afc9b69500
commit
55d903947e
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace app\common\dao\marketing\activity;
|
||||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\marketing\activity\Record;
|
||||
|
||||
class RecordDao extends BaseDao{
|
||||
|
||||
protected function getModel(): string{
|
||||
return Record::class;
|
||||
}
|
||||
/**
|
||||
* Common: 公共搜索模型
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 18:53
|
||||
* @param array $params
|
||||
* @return Record
|
||||
*/
|
||||
public function searchList(array $params){
|
||||
return (new Record())
|
||||
->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){
|
||||
$query->where('id', (int)$params['id']);
|
||||
})
|
||||
->order('create_time DESC,id DESC');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ class StoreGroupOrderDao extends BaseDao
|
|||
$query = StoreGroupOrder::getDB()->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
|
||||
$query->where('paid', $where['paid']);
|
||||
})
|
||||
->whereNotIn('activity_type', [30,31,32])
|
||||
->whereNotIn('activity_type', [30,31,32,33])
|
||||
->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
|
||||
$query->where('paid', $where['paid']);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ExchangeQuotaDao extends BaseDao{
|
|||
*/
|
||||
public function searchModel(array $params){
|
||||
$quotaType = $params['quota_type'] ?? 1;// 存在指定类型则使用指定类型,否则使用默认类型(默认酒卡)
|
||||
$quotaType = in_array((int)$quotaType,[1,2]) ? $quotaType : 1;// 类型非法,使用默认类型
|
||||
$quotaType = in_array((int)$quotaType,[1,2,3,4]) ? $quotaType : 1;// 类型非法,使用默认类型
|
||||
|
||||
return (new ExchangeQuota())
|
||||
->where('quota_type', $quotaType)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace app\common\model\marketing\activity;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
|
||||
class Record extends BaseModel{
|
||||
|
||||
|
||||
public static function tablePk():string{
|
||||
return 'id';
|
||||
}
|
||||
public static function tableName():string{
|
||||
return 'activity_record';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,11 +3,17 @@
|
|||
namespace app\common\repositories\marketing\activity;
|
||||
|
||||
use app\common\dao\marketing\activity\ActivityDao;
|
||||
use app\common\model\marketing\AgentApply;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\marketing\AgentRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use crmeb\services\LockService;
|
||||
use FormBuilder\Factory\Elm;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Route;
|
||||
|
||||
class ActivityRepository extends BaseRepository{
|
||||
|
|
@ -75,6 +81,7 @@ class ActivityRepository extends BaseRepository{
|
|||
Elm::number('vegetable_quota','赠送菜卡额度')->required()->col(12)->min(0),
|
||||
Elm::number('oil_quota','赠送油卡额度')->required()->col(12)->min(0),
|
||||
Elm::number('wine_quota','赠送封坛酒额度')->required()->col(12)->min(0),
|
||||
Elm::number('money','参加支付金额')->required()->col(24)->min(0),
|
||||
Elm::select('mer_id', '参与烟酒馆')->options(function () {
|
||||
return app()->make(MerchantRepository::class)
|
||||
->getSearch(['mer_state' => 1,'merchant_type' => 3, 'status' => 1, 'is_del' => 0])
|
||||
|
|
@ -116,6 +123,7 @@ class ActivityRepository extends BaseRepository{
|
|||
'vegetable_quota' => $params['vegetable_quota'],
|
||||
'oil_quota' => $params['oil_quota'],
|
||||
'wine_quota' => $params['wine_quota'],
|
||||
'money' => $params['money'],
|
||||
'mer_id' => is_array($params['mer_id']) ? implode(',',$params['mer_id']) : $params['mer_id'],
|
||||
'coupon_ids' => is_array($params['coupon_ids']) ? implode(',',$params['coupon_ids']) : $params['coupon_ids'],
|
||||
];
|
||||
|
|
@ -127,8 +135,4 @@ class ActivityRepository extends BaseRepository{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\repositories\marketing\activity;
|
||||
|
||||
use app\common\dao\marketing\activity\RecordDao;
|
||||
use app\common\model\marketing\activity\Activity;
|
||||
use app\common\model\marketing\activity\Record;
|
||||
use app\common\model\user\ExchangeQuotaRecord;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||
use app\common\repositories\store\order\StoreOrderCreateRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use app\common\repositories\user\ExchangeQuotaRepository;
|
||||
use crmeb\services\LockService;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class RecordRepository extends BaseRepository{
|
||||
|
||||
protected $dao;
|
||||
|
||||
public function __construct(RecordDao $dao){
|
||||
$this->dao = $dao;
|
||||
}
|
||||
/**
|
||||
* Common: 公共查询模型
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 18:54
|
||||
* @param $search
|
||||
* @return \app\common\model\marketing\activity\Record
|
||||
*/
|
||||
public function getSearchModel($search){
|
||||
return $this->dao->searchList($search);
|
||||
}
|
||||
/**
|
||||
* Common: 获取信息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 18:55
|
||||
* @param array $params
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList(array $params,int $page,int $limit):array{
|
||||
$query = $this->dao->searchList($params);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page,$limit)->select()->toArray();
|
||||
|
||||
return compact('count','list');
|
||||
}
|
||||
/**
|
||||
* Common: 加入活动处理
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 19:09
|
||||
* @param $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function joinActivityHandle($params){
|
||||
return Db::transaction(function() use ($params){
|
||||
// 获取活动信息
|
||||
$activityInfo = Activity::where('id', $params['activity_id'])->findOrEmpty()->toArray();
|
||||
// 生成记录信息
|
||||
$recordInfo = [
|
||||
'uid' => $params['uid'],
|
||||
'mer_id' => $params['mer_id'],
|
||||
'activity_id' => $params['activity_id'],
|
||||
'money' => $activityInfo['money'],
|
||||
'status' => $activityInfo['money'] > 0 ? 0 : 2,
|
||||
];
|
||||
$recordId = Record::insertGetId($recordInfo);
|
||||
// 判断:是否需要支付 需要支付生成订单并且获取支付信息
|
||||
$payResult = [];
|
||||
$payInfo = [
|
||||
'pay_type' => $params['pay_type'],
|
||||
'return_url' => $params['return_url'],
|
||||
];
|
||||
if((float)$activityInfo['money'] > 0){
|
||||
// 需要支付
|
||||
$userInfo = $params['user_info'] ?? [];
|
||||
$payInfo['money'] = (float)$activityInfo['money'];
|
||||
// 发起支付
|
||||
$groupOrder = app()
|
||||
->make(LockService::class)
|
||||
->exec('online_order.create',function() use ($payInfo,$userInfo){
|
||||
$payType = array_search($payInfo['pay_type'],StoreOrderRepository::PAY_TYPE);
|
||||
return app()
|
||||
->make(StoreOrderCreateRepository::class)
|
||||
->onlinePayment($payType,$payInfo,$userInfo, 33);
|
||||
});
|
||||
// 子订单只存在一个 直接查询即可
|
||||
$orderId = app()->make(StoreOrderRepository::class)
|
||||
->getSearch([])
|
||||
->where('group_order_id',$groupOrder->group_order_id)
|
||||
->value('order_id');
|
||||
Record::update(['order_id'=>$orderId],['id'=>$recordId]);
|
||||
$payResult = app()
|
||||
->make(StoreOrderRepository::class)
|
||||
->pay($payInfo['pay_type'],$userInfo,$groupOrder,$payInfo['return_url'],$params['is_app']);
|
||||
}else{
|
||||
// 无需支付
|
||||
$this->joinActivitySuccess((int)$recordId);
|
||||
}
|
||||
|
||||
return $payResult;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Common: 加入活动成功处理(包括支付成功后处理)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 20:16
|
||||
* @param int $recordId
|
||||
*/
|
||||
public function joinActivitySuccess(int $recordId){
|
||||
// 获取记录id
|
||||
$recordInfo = $this->getSearchModel(['id'=>$recordId])->findOrEmpty()->toArray();
|
||||
// 获取活动信息
|
||||
$activityInfo = Activity::where('id', $recordInfo['activity_id'])->findOrEmpty()->toArray();
|
||||
$activityInfo['coupon_ids'] = $activityInfo['coupon_ids'] ? explode(',', $activityInfo['coupon_ids']) : [];
|
||||
// 判断:是否赠送酒卡额度
|
||||
if($activityInfo['quota'] > 0) $this->giveQuota((float)$activityInfo['quota'], (int)1, (int)$recordInfo['uid'], (int)$recordInfo['order_id']);
|
||||
// 判断:是否赠送菜卡额度
|
||||
if($activityInfo['vegetable_quota'] > 0) $this->giveQuota((float)$activityInfo['quota'], (int)2, (int)$recordInfo['uid'], (int)$recordInfo['order_id']);
|
||||
// 判断:是否赠送油卡额度
|
||||
if($activityInfo['oil_quota'] > 0) $this->giveQuota((float)$activityInfo['quota'], (int)3, (int)$recordInfo['uid'], (int)$recordInfo['order_id']);
|
||||
// 判断:是否赠送封坛酒卡额度
|
||||
if($activityInfo['wine_quota'] > 0) $this->giveQuota((float)$activityInfo['quota'], (int)4, (int)$recordInfo['uid'], (int)$recordInfo['order_id']);
|
||||
// 是否赠送优惠券
|
||||
if(count($activityInfo['coupon_ids']) > 0){
|
||||
$uid = $recordInfo['uid'];
|
||||
foreach($activityInfo['coupon_ids'] as $coupon_id){
|
||||
$coupon = app()->make(StoreCouponRepository::class)->validSvipCouponTwo($coupon_id,$uid);
|
||||
if (!$coupon) continue;//throw new ValidateException('优惠券失效');
|
||||
// 获取商户id 和关联的品牌ID
|
||||
$bindShop = [];
|
||||
if((int)$recordInfo['mer_id'] > 0){
|
||||
$bindShop = app()->make(MerchantRepository::class)->getSearch([])
|
||||
->where('mer_id', $recordInfo['mer_id'])
|
||||
->where('is_del', 0)
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
}
|
||||
$params = [
|
||||
'shop_mer_id' => $bindShop['mer_id'] ?? 0,
|
||||
'brand_id' => $bindShop['brand_id'] ?? 0,
|
||||
'user_order_id' => $recordInfo['order_id'] ?? 0,
|
||||
];
|
||||
|
||||
app()->make(StoreCouponRepository::class)->sendCoupon($coupon, $uid,StoreCouponUserRepository::SEND_TYPE_BUY, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common: 各种额度变更(赠送变更)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 20:07
|
||||
* @param float $num 变更数量
|
||||
* @param int $quotaType 1=酒卡额度,2=菜卡额度,3=封坛酒额度,4=加油卡额度
|
||||
* @param int $uid 用户id
|
||||
* @param int $orderId 订单id
|
||||
*/
|
||||
public function giveQuota(float $num,int $quotaType,int $uid,int $orderId){
|
||||
$holdInfo = app()->make(ExchangeQuotaRepository::class)->searchModel(['uid'=>$uid,'quota_type'=>$quotaType])->findOrEmpty();
|
||||
if((int)$holdInfo->uid <= 0) {
|
||||
$holdInfo->uid = $uid;
|
||||
$holdInfo->quota_type = $quotaType;
|
||||
}
|
||||
// 赠送
|
||||
$changeFront = (float)$holdInfo->surplus_quota;
|
||||
$holdInfo->total_quota += (float)$num;// 总额度
|
||||
$holdInfo->surplus_quota += (float)$num;// 剩余额度
|
||||
$holdInfo->save();
|
||||
// 记录
|
||||
ExchangeQuotaRecord::insert([
|
||||
'uid' => $uid,
|
||||
'product_id' => 0,
|
||||
'order_id' => $orderId,
|
||||
'order_product_id' => 0,
|
||||
'change_type' => 1,
|
||||
'change_quantity' => (float)$num,
|
||||
'change_front' => $changeFront,
|
||||
'change_after' => (float)$holdInfo->surplus_quota,
|
||||
'remark' => "参加活动赠送",
|
||||
'source' => 5,
|
||||
'quota_type' => $quotaType,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3005,7 +3005,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
// 整理订单数据
|
||||
$orderList[] = [
|
||||
'cartInfo' => [],
|
||||
'activity_type' => $activityType,// 30=在线买单;32=代理入驻
|
||||
'activity_type' => $activityType,// 30=在线买单;32=代理入驻;33=参加活动支付
|
||||
'commission_rate' => 0,
|
||||
'order_type' => 0,
|
||||
'is_virtual' => 1,
|
||||
|
|
@ -3058,7 +3058,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
|
|||
'integral' => 0,
|
||||
'integral_price' => 0,
|
||||
'give_integral' => 0,
|
||||
'activity_type' => $activityType,// 30=在线买单;32=代理入驻
|
||||
'activity_type' => $activityType,// 30=在线买单;32=代理入驻;33=参加活动支付
|
||||
];
|
||||
$group = Db::transaction(function() use ($user,$groupOrder,$orderList){
|
||||
$storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ class StoreOrderRepository extends BaseRepository
|
|||
}else if($groupOrder['activity_type'] == 32){
|
||||
$data['title'] = '用户申请成为代理人员';
|
||||
$data['mark'] = '余额支付' . floatval($groupOrder['pay_price']) . '元';
|
||||
}else if($groupOrder['activity_type'] == 33){
|
||||
$data['title'] = '用户参加活动';
|
||||
$data['mark'] = '余额支付' . floatval($groupOrder['pay_price']) . '元';
|
||||
}else if($groupOrder['activity_type'] == 35){
|
||||
$merName = Merchant::where('mer_id',$groupOrder->with_goods_mer_id)->value('mer_name');
|
||||
$data['title'] = '酒道馆['.$merName.']进货';
|
||||
|
|
@ -276,7 +279,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
app()->make(ProductAssistSetRepository::class)->changStatus($order->orderProduct[0]['activity_id']);
|
||||
}
|
||||
if ($order->order_type == 1 && $order->status != 10) $order->verify_code = $this->verifyCode();
|
||||
if (!in_array($order->activity_type,[30,31,32]) && $order->orderProduct[0]->product->type == 2) {
|
||||
if (!in_array($order->activity_type,[30,31,32,33]) && $order->orderProduct[0]->product->type == 2) {
|
||||
$order->status = 2;
|
||||
$order->delivery_type = 6;
|
||||
$order->delivery_name = '自动发货';
|
||||
|
|
@ -284,7 +287,7 @@ class StoreOrderRepository extends BaseRepository
|
|||
$isPoints = true;
|
||||
}
|
||||
// 判断:是否为在线买单、酒道馆补差价 在线买单,订单支付则订单完成
|
||||
if(in_array($order->activity_type,[30,31,32])){
|
||||
if(in_array($order->activity_type,[30,31,32,33])){
|
||||
$order->status = 3;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Activity extends BaseController{
|
|||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function editInfo(){
|
||||
$params = $this->request->params(['title','cate_id','quota','vegetable_quota','oil_quota','wine_quota','mer_id','coupon_ids','image',['id', 0]]);
|
||||
$params = $this->request->params(['title','cate_id','quota','vegetable_quota','oil_quota','wine_quota','mer_id','coupon_ids','image','money',['id', 0]]);
|
||||
$this->repository->submitEditFormData($params);
|
||||
|
||||
return app('json')->success('编辑成功');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
namespace app\controller\api;
|
||||
|
||||
|
||||
use app\common\repositories\marketing\activity\ActivityRepository;
|
||||
use app\common\repositories\marketing\activity\RecordRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
class Activity extends BaseController{
|
||||
|
||||
protected $repository;
|
||||
|
||||
public function __construct(App $app, ActivityRepository $repository){
|
||||
parent::__construct($app);
|
||||
$this->repository = $repository;
|
||||
}
|
||||
/**
|
||||
* Common: 获取详情
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 17:22
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function detail($id){
|
||||
$info = $this->repository->getSearchModel(['id'=>$id])->findOrEmpty()->toArray();
|
||||
|
||||
return app('json')->success($info);
|
||||
}
|
||||
/**
|
||||
* Common: 申请参加活动
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/14 19:09
|
||||
* @return mixed
|
||||
*/
|
||||
public function joinActivity(){
|
||||
// 获取申请参数
|
||||
$params = $this->request->params([
|
||||
['activity_id',0],
|
||||
['mer_id',0],
|
||||
// 支付相关
|
||||
'pay_type',
|
||||
'return_url'
|
||||
]);
|
||||
if($params['activity_id'] <= 0) throw new ValidateException('活动不存在或者已经结束!');
|
||||
if($params['mer_id'] <= 0) throw new ValidateException('请选择烟酒店!');
|
||||
// 处理数据
|
||||
$params['uid'] = $this->request->uid();
|
||||
$params['user_info'] = $this->request->userInfo();
|
||||
$params['is_app'] = $this->request->isApp();
|
||||
|
||||
$res = app()->make(RecordRepository::class)->joinActivityHandle($params);
|
||||
|
||||
if($res) return $res;
|
||||
else return app('json')->success("操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -16,15 +16,21 @@ class OnlinePay extends BaseController{
|
|||
* @return mixed
|
||||
*/
|
||||
public function searchMer(){
|
||||
$search = $this->request->params(['search_text','mer_id']);
|
||||
$search = $this->request->params(['search_text','mer_id','merchant_type','lat','lng']);
|
||||
// if(empty($search['search_text'])) return app('json')->fail('请输入搜索内容!');
|
||||
// 内容查询
|
||||
$list = app()->make(MerchantRepository::class)
|
||||
->getSearch([])
|
||||
->field('mer_id,mer_name,mer_address,mer_avatar')
|
||||
->where('is_del',0)
|
||||
->where('mer_state', 1)
|
||||
->where('status', 1)
|
||||
->when((isset($search['lng']) && $search['lng'] > 0) && (isset($search['lat']) && $search['lat'] > 0),function($query) use ($search){
|
||||
$distance = "ROUND((ST_DISTANCE(point(`long`, lat), point({$search['lng']}, {$search['lat']})) * 111195),2)";
|
||||
$query->field("mer_id,mer_name,mer_address,mer_avatar,{$distance} as distance")
|
||||
->orderRaw("{$distance} ASC");
|
||||
},function($query){
|
||||
$query->field('mer_id,mer_name,mer_address,mer_avatar');
|
||||
})
|
||||
->where(function($query) use ($search){
|
||||
$query->where('mer_name','like',"%{$search['search_text']}%")
|
||||
->whereOr('mer_address','like',"%{$search['search_text']}%");
|
||||
|
|
@ -32,10 +38,21 @@ class OnlinePay extends BaseController{
|
|||
->when((int)$search['mer_id'] > 0,function($query) use ($search){
|
||||
$query->where('mer_id',$search['mer_id']);
|
||||
})
|
||||
->when((int)$search['merchant_type'] > 0,function($query) use ($search){
|
||||
$query->where('merchant_type',$search['merchant_type']);
|
||||
})
|
||||
->order('create_time desc,mer_id desc')
|
||||
->limit(100)
|
||||
->select()
|
||||
->toArray();
|
||||
->select()->each(function($item){
|
||||
$item->distance = $item->distance ?? 0;
|
||||
$item->distance_text = '';
|
||||
if($item->distance > 0){
|
||||
if ($item->distance < 100) $item->distance_text = '100m以内';
|
||||
else $item->distance_text = sprintf("%.2f",$item->distance / 1000).'km';
|
||||
}
|
||||
|
||||
return $item;
|
||||
});;
|
||||
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace app\listener\exchangeQuota;
|
||||
|
||||
use app\common\model\marketing\activity\Record;
|
||||
use app\common\model\user\ExchangeIntegralRecord;
|
||||
use app\common\model\user\ExchangeQuota;
|
||||
use app\common\model\user\ExchangeQuotaRecord;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\marketing\activity\RecordRepository;
|
||||
use app\common\repositories\marketing\AgentBrokerageRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use app\common\repositories\user\ExchangePickupPointRepository;
|
||||
|
|
@ -30,8 +32,11 @@ class OrderPaySuccessEvent{
|
|||
// 兑换商品补差价处理
|
||||
$this->exchangeGoodsHandle($groupOrder);
|
||||
}else if($groupOrder->activity_type == 32){
|
||||
// 代理入驻支付
|
||||
// 代理入驻支付
|
||||
$this->agentPaySuccessHandle($groupOrder);
|
||||
}else if($groupOrder->activity_type == 33){
|
||||
// 加入活动支付成功
|
||||
$this->joinActivitySuccessHandle($groupOrder);
|
||||
}else{
|
||||
// 其他订单
|
||||
$this->orderPaySuccessHandle($groupOrder);
|
||||
|
|
@ -50,6 +55,8 @@ class OrderPaySuccessEvent{
|
|||
Log::info('支付成功 - 兑换商品补差价处理 - 错误: '.var_export($data,1));
|
||||
}else if($groupOrder->activity_type == 32){
|
||||
Log::info('支付成功 - 邀请代理人员奖励及免审核 - 错误: '.var_export($data,1));
|
||||
}else if($groupOrder->activity_type == 33){
|
||||
Log::info('支付成功 - 加入活动支付成功 - 错误: '.var_export($data,1));
|
||||
}else{
|
||||
Log::info('支付成功 - 赠送酒卡额度 - 错误: '.var_export($data,1));
|
||||
}
|
||||
|
|
@ -177,6 +184,16 @@ class OrderPaySuccessEvent{
|
|||
|
||||
return true;
|
||||
}
|
||||
// 支付成功 - 加入活动支付成功
|
||||
public function joinActivitySuccessHandle($groupOrder){
|
||||
foreach($groupOrder->orderList as $orderInfo){
|
||||
$recordId = (int)Record::where('order_id', (int)$orderInfo->order_id)->value('id');
|
||||
if($recordId > 0) app()->make(RecordRepository::class)->joinActivitySuccess((int)$recordId);
|
||||
// 修改状态
|
||||
Record::where('order_id', (int)$orderInfo->order_id)->update(['status'=>1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -422,8 +422,6 @@ Route::group('api/', function () {
|
|||
Route::post('cart_del','cartDel');// 删除购物车商品
|
||||
|
||||
})->prefix('api.Supplier/')->middleware(ShopTokenMiddleware::class,TRUE);
|
||||
|
||||
|
||||
// 酒道馆商品兑换相关接口
|
||||
Route::group('wine',function(){
|
||||
Route::get('list','merList');// 全部酒道馆
|
||||
|
|
@ -435,6 +433,14 @@ Route::group('api/', function () {
|
|||
Route::post('cart_del','cartDel');// 删除购物车商品
|
||||
|
||||
})->prefix('api.Wine/');
|
||||
// 活动中心相关接口
|
||||
Route::group('activity', function () {
|
||||
Route::get('detail/:id', 'detail');
|
||||
Route::get('joinActivity', 'joinActivity');
|
||||
|
||||
|
||||
})->prefix('api.Activity/');
|
||||
|
||||
|
||||
})->middleware(UserTokenMiddleware::class, true);
|
||||
//非强制登录
|
||||
|
|
|
|||
Loading…
Reference in New Issue