Commit 9cb71cbf authored by hujun's avatar hujun

记录

parent 84647a34
...@@ -30,14 +30,12 @@ class CouponService{ ...@@ -30,14 +30,12 @@ class CouponService{
* 发券 * 发券
* *
* @param int $user_id * @param int $user_id
* @param int $type 奖励动作 0首次登陆 1邀请登陆 2邀请成交 * @param int $referrer_id
* @param int $report_id * @param int $type
* @param int $bargain_id
* @param int $order_id
* @return mixed * @return mixed
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function sendCoupon(int $user_id, int $type, $report_id = 0, $bargain_id = 0, $order_id = 0) { public function sendCoupon(int $user_id, int $referrer_id,int $type) {
$result['status'] = 'successful'; $result['status'] = 'successful';
$result['msg'] = '发券成功'; $result['msg'] = '发券成功';
$result['data'] = []; $result['data'] = [];
...@@ -49,7 +47,7 @@ class CouponService{ ...@@ -49,7 +47,7 @@ class CouponService{
$result['msg'] = '正在发券中,请稍等...'; $result['msg'] = '正在发券中,请稍等...';
return $result; return $result;
} else { } else {
$this->redis_->set($key, $user_id, 3); //上线后改为120 $this->redis_->set($key, $user_id, 3);
} }
try { try {
...@@ -60,7 +58,7 @@ class CouponService{ ...@@ -60,7 +58,7 @@ class CouponService{
return $result; return $result;
} }
$activity_data = $this->checkUserCoupon($user_id, $type, $order_id); $activity_data = $this->checkUserCoupon($user_id, $type, $referrer_id);
if (empty($activity_data)) { if (empty($activity_data)) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = '没有可参加的活动'; $result['msg'] = '没有可参加的活动';
...@@ -68,14 +66,8 @@ class CouponService{ ...@@ -68,14 +66,8 @@ class CouponService{
} }
$save_data = []; $save_data = [];
$save_data['user_id'] = $user_id; $save_data['user_id'] = $user_id;
if ($report_id) { if ($referrer_id) {
$save_data['report_id'] = $report_id; $save_data['referrer_id'] = $referrer_id;
}
if ($bargain_id) {
$save_data['bargain_id'] = $bargain_id;
}
if ($order_id) {
$save_data['order_id'] = $order_id;
} }
$save_data['status'] = 0; $save_data['status'] = 0;
$save_data['create_time'] = date('Y-m-d H:i:s'); $save_data['create_time'] = date('Y-m-d H:i:s');
...@@ -137,7 +129,7 @@ class CouponService{ ...@@ -137,7 +129,7 @@ class CouponService{
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function checkUserCoupon(int $user_id, int $type, $order_id) public function checkUserCoupon(int $user_id, int $type, $referrer_id)
{ {
$return_activity = []; $return_activity = [];
$time = time(); $time = time();
...@@ -145,14 +137,14 @@ class CouponService{ ...@@ -145,14 +137,14 @@ class CouponService{
$field .= ',available,get_number,create_time'; $field .= ',available,get_number,create_time';
$activity_data = $this->selectActivity($field, $type); $activity_data = $this->selectActivity($field, $type);
$count_where['user_id'] = $user_id; $count_where['user_id'] = $user_id;
foreach ($activity_data as $k=>$v) { foreach ($activity_data as $k=>$v) {
if ($v['total'] - $v['get_number'] <= 0 ) { if ($v['total'] - $v['get_number'] <= 0 ) {
continue; continue;
} }
//单个订单只奖励一次 if ($type == 0) {
if ($type == 2) { $count_where['referrer_id'] = $referrer_id;
$count_where['order_id'] = $order_id;
$num = $this->m_coupon->getCount($count_where); $num = $this->m_coupon->getCount($count_where);
if ($num > 0) { if ($num > 0) {
continue; continue;
......
...@@ -125,11 +125,11 @@ class RegisterService ...@@ -125,11 +125,11 @@ class RegisterService
$coupon_service = new CouponService(); $coupon_service = new CouponService();
if (!empty($first_login_time)) { if (!empty($first_login_time)) {
$coupon_service->sendCoupon((int)$id, 0); $coupon_service->sendCoupon((int)$id, $user_info[0]['referrer_id'], 0);
} }
if (!empty($registration_time) && $referrer_source == 10 && $referrer_id) { if (!empty($registration_time) && $referrer_source == 10 && $referrer_id) {
$coupon_service->sendCoupon((int)$referrer_id, 2); $coupon_service->sendCoupon((int)$referrer_id, 0, 2);
} }
$jwt = new JwtUntils(); $jwt = new JwtUntils();
......
...@@ -1423,7 +1423,7 @@ class Finance extends Basic ...@@ -1423,7 +1423,7 @@ class Finance extends Basic
*/ */
public function addRealIncome() public function addRealIncome()
{ {
if (empty($this->params['bargain_id']) || !isset($this->params['is_account_commission']) || !isset($this->params['is_account_commission'])) { if (empty($this->params['bargain_id']) || !isset($this->params['is_account_commission'])) {
return $this->response(101, '请求参数错误'); return $this->response(101, '请求参数错误');
} }
...@@ -1473,7 +1473,7 @@ class Finance extends Basic ...@@ -1473,7 +1473,7 @@ class Finance extends Basic
$user_id = $m_report->getFieldValue('user_id',['id'=>$this->params['report_id']]); $user_id = $m_report->getFieldValue('user_id',['id'=>$this->params['report_id']]);
if ($user_id) { if ($user_id) {
$service = new ConvertCouponService(); $service = new ConvertCouponService();
$service->convertCoupon($user_id); //核销红包 $service->convertCoupon($user_id, $this->params['report_id'], $this->params['bargain_id'], $this->params['order_id']); //核销红包
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment