136 行
4.1 KiB
PHP
可执行文件
136 行
4.1 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Common\Business;
|
|
|
|
use Common\Model\RetailVipRechargeModel;
|
|
//[1.7.14]
|
|
/**
|
|
* 会员充值活动类
|
|
* Class VipRechargeActivity
|
|
* [
|
|
* 获取充值活动最大的赠送金额 getMaxGiveMoney
|
|
* 依据活动id查询可使用的活动信息 basisIdGetInfo
|
|
* ]
|
|
* @package Common\Business
|
|
*/
|
|
class VipRechargeActivity
|
|
{
|
|
/**
|
|
* 获取充值活动最大的赠送金额
|
|
* @param $param
|
|
* [
|
|
* merchant_id
|
|
* store_id
|
|
* recharge_money 充值金额
|
|
* activity_type 1线上活动 2线下活动
|
|
* user_type 用户类型 2.plus会员 3.普通会员
|
|
* ]
|
|
* @return bool|int
|
|
* [
|
|
* data 活动信息
|
|
* ]
|
|
*/
|
|
public function getMaxGiveMoney($param)
|
|
{
|
|
$time = time();
|
|
$where = [
|
|
'merchant_id' => $param['merchant_id'],
|
|
'store_id' => $param['store_id'],
|
|
'status' => 1,
|
|
'state' => 1,
|
|
'recharge_money' => ['elt', $param['recharge_money']],
|
|
'surplus' => ['eq', '-1', ['gt', 0], 'or'],
|
|
'start_time' => [['eq', ''], ['lt', $time], 'or'],
|
|
'end_time' => [['eq', ''], ['gt', $time], 'or'],
|
|
'role_type' => $param['user_type'] ? $param['user_type'] : 3,
|
|
'scene_type' => 1
|
|
];
|
|
switch ($param['activity_type']) {
|
|
case 1:
|
|
//线上
|
|
$where['online_state'] = 1;
|
|
break;
|
|
case 2:
|
|
//线下
|
|
$where['line_state'] = 1;
|
|
break;
|
|
}
|
|
$fields = [
|
|
'id',
|
|
'recharge_money',
|
|
'give_money',
|
|
'surplus',
|
|
'limit_num',
|
|
'aging_repay',
|
|
'aging_time'
|
|
];
|
|
try {
|
|
$VipRechargeModel = new RetailVipRechargeModel();
|
|
$activity = $VipRechargeModel->getOrderFind($where, $fields, 'give_money desc');
|
|
$activity = $activity ? $activity : [];
|
|
return callBack(statusCode()['success'], "活动最大的赠送金额查询成功", $activity);
|
|
} catch (\Exception $e) {
|
|
return callBack(statusCode()['error'], "活动最大的赠送金额查询失败");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 依据活动id查询可使用的活动信息
|
|
* @param $param
|
|
* [
|
|
* merchant_id
|
|
* store_id
|
|
* id 活动id
|
|
* activity_type 1线上活动 2线下活动
|
|
* ]
|
|
* @return mixed
|
|
* [
|
|
* data 活动信息
|
|
* ]
|
|
*/
|
|
public function basisIdGetInfo($param)
|
|
{
|
|
// 充值活动查询条件
|
|
$time = time();
|
|
$where = [
|
|
'id' => $param['id'],
|
|
'merchant_id' => $param['merchant_id'],
|
|
'store_id' => $param['store_id'],
|
|
'status' => 1,
|
|
'state' => 1,
|
|
'surplus' => [['gt', 0], ['eq', '-1'], 'or'],
|
|
'start_time' => [['eq', ''], ['lt', $time], 'or'],
|
|
'end_time' => [['eq', ''], ['gt', $time], 'or']
|
|
];
|
|
switch ($param['activity_type']) {
|
|
case 1:
|
|
//线上活动
|
|
$where['online_state'] = 1;
|
|
break;
|
|
case 2:
|
|
//线下活动
|
|
$where['line_state'] = 1;
|
|
break;
|
|
}
|
|
$fields = [
|
|
'id',
|
|
'recharge_money',
|
|
'give_money',
|
|
'surplus',
|
|
'limit_num',
|
|
'aging_repay',
|
|
'aging_time'
|
|
];
|
|
try {
|
|
$VipRechargeModel = new RetailVipRechargeModel();
|
|
$info = $VipRechargeModel->getFind($where, $fields);
|
|
if (!empty($info)) {
|
|
return callBack(statusCode()['success'], "充值活动查询成功", $info);
|
|
} else {
|
|
return callBack(statusCode()['error'], "充值活动查询失败");
|
|
}
|
|
} catch (\Exception $e) {
|
|
return callBack(statusCode()['error'], "充值活动查询失败");
|
|
}
|
|
}
|
|
} |