Commit 7c3d874c authored by hujun's avatar hujun

确认分佣-红包列表

parent 6cd5f736
...@@ -53,21 +53,13 @@ class CouponService{ ...@@ -53,21 +53,13 @@ class CouponService{
} }
try { try {
$user_data = $this->m_user->getUserById('id,first_login_time', $user_id, ['status'=>0]); $user_data = $this->m_user->getUserById('id', $user_id, ['status'=>0]);
if (empty($user_data['id'])) { if (empty($user_data['id'])) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = '该用户不存在'; $result['msg'] = '该用户不存在';
return $result; return $result;
} }
//该笔订单的收意向金时间48小时前 才给成交人和邀请人的返现红包兑现
$time = time() - 172800;
if ($type == 0 && strtotime($user_data['first_login_time']) < $time) {
$result['status'] = 'fail';
$result['msg'] = '该用户首次登陆时间未超过48小时';
return $result;
}
$activity_data = $this->checkUserCoupon($user_id, $type, $order_id); $activity_data = $this->checkUserCoupon($user_id, $type, $order_id);
if (empty($activity_data)) { if (empty($activity_data)) {
$result['status'] = 'fail'; $result['status'] = 'fail';
...@@ -111,15 +103,14 @@ class CouponService{ ...@@ -111,15 +103,14 @@ class CouponService{
/** /**
* 查询奖励动作 * 查询奖励动作
* *
* @param string $field
* @param $return_action @奖励动作 0首次登陆 1邀请登陆 2邀请成交 * @param $return_action @奖励动作 0首次登陆 1邀请登陆 2邀请成交
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function selectActivity($return_action) { public function selectActivity($field = 'id', $return_action) {
$field = 'id,return_type,money,activity_start_time,activity_end_time,use_period,total,available,total';
$field .= ',available,get_number';
$where['total'] = ['>', 0]; $where['total'] = ['>', 0];
if (is_array($return_action)) { if (is_array($return_action)) {
...@@ -150,7 +141,9 @@ class CouponService{ ...@@ -150,7 +141,9 @@ class CouponService{
{ {
$return_activity = []; $return_activity = [];
$time = time(); $time = time();
$activity_data = $this->selectActivity($type); $field = 'id,return_type,money,activity_start_time,activity_end_time,use_period,total,available,total';
$field .= ',available,get_number,create_time';
$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 ) {
......
...@@ -123,6 +123,15 @@ class RegisterService ...@@ -123,6 +123,15 @@ class RegisterService
$jwt_data['userNick'] = $user_nick; $jwt_data['userNick'] = $user_nick;
$jwt_data['phone'] = $phone; $jwt_data['phone'] = $phone;
$coupon_service = new CouponService();
if (!empty($first_login_time)) {
$coupon_service->sendCoupon((int)$id, 0);
}
if (!empty($registration_time) && $referrer_source == 10 && $referrer_id) {
$coupon_service->sendCoupon((int)$referrer_id, 2);
}
$jwt = new JwtUntils(); $jwt = new JwtUntils();
$AuthToken = $jwt->createToken($jwt_data); $AuthToken = $jwt->createToken($jwt_data);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace app\index\controller; namespace app\index\controller;
use app\api\service\ConvertCouponService;
use app\api\service\CouponService;
use app\api_broker\service\OrderLogService; use app\api_broker\service\OrderLogService;
use app\api_broker\service\PayLogService; use app\api_broker\service\PayLogService;
use app\api_broker\service\VipService; use app\api_broker\service\VipService;
...@@ -694,14 +696,67 @@ class Finance extends Basic ...@@ -694,14 +696,67 @@ class Finance extends Basic
$m_report = new OReportModel(); $m_report = new OReportModel();
$m_user = new Users(); $m_user = new Users();
$user_id = $m_report->getFieldValue('user_id', ['id'=>$report_id]); $user_id = $m_report->getFieldValue('user_id', ['id'=>$report_id]);
$referrer_id = $m_user->getUserByWhereValue('referrer_id', ['id'=>$user_id,'referrer_source'=>10]); $id = $m_user->getUserByWhereValue('id', ['id'=>$user_id,'referrer_source'=>10,'status'=>0]);
$is_show = 0; $is_show = 0;
if ($referrer_id) { if ($id) {
$is_show = 1; $is_show = 1;
} }
return $this->response(200,'', ['is_show'=>$is_show]); return $this->response(200,'', ['is_show'=>$is_show]);
} }
/**
* 确认分佣红包列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getActivityCoupon()
{
$report_id = $this->params['report_id'];
$report_id = 359;
if (empty($report_id)) {
return $this->response(101, '参数错误');
}
$referrer_data = [];
$m_report = new OReportModel();
$m_user = new Users();
$user_id = $m_report->getFieldValue('user_id', ['id'=>$report_id]);
$user_data = $m_user->getUserById('id,user_phone,referrer_id,referrer_source', $user_id, ['status'=>0]); //被邀请人
if ($user_data) {
if ($user_data['referrer_source'] == 10) {
$referrer_data = $m_user->getUserById('id,user_phone', $user_data['referrer_id'], ['status'=>0]); //邀请人
}
$server = new CouponService();
$activity_data = $server->selectActivity('title,use_period,money',[0,2]);
foreach ($activity_data as $k=>$v) {
if ($v['return_action'] == 0) {
$data[0]['id'] = $user_data['id'];
$data[0]['title'] = $v['title'];
$data[0]['money'] = $v['money'];
$validity = time() + $v['use_period'] * 86400;
$data[0]['validity'] = date('Y.m.d').'-'.date('Y.m.d', $validity);
$data[0]['phone'] = substr_replace($user_data['user_phone'], '****', 3, 4);
$data[0]['user_type'] = '成交人';
}
if ($v['return_action'] == 0 && $referrer_data) {
$data[1]['id'] = $referrer_data['id'];
$data[1]['title'] = $v['title'];
$data[1]['money'] = $v['money'];
$validity = time() + $v['use_period'] * 86400;
$data[1]['validity'] = date('Y.m.d').'-'.date('Y.m.d', $validity);
$data[1]['phone'] = substr_replace($referrer_data['user_phone'], '****', 3, 4);
$data[1]['user_type'] = '邀请人';
}
}
}
return $this->response(200,'', $data);
}
/** /**
* 收款记录 * 收款记录
* *
...@@ -1372,7 +1427,7 @@ class Finance extends Basic ...@@ -1372,7 +1427,7 @@ class Finance extends Basic
return $this->response(101, '请求参数错误'); return $this->response(101, '请求参数错误');
} }
$bargain_data = $this->m_bargain->getCheckBargain('a.id,a.agent_id,a.role,a.create_time,d.store_id,d.district_id', $this->params['bargain_id']); $bargain_data = $this->m_bargain->getCheckBargain('a.id,a.agent_id,a.role,a.create_time,d.store_id,d.district_id,a.report_id', $this->params['bargain_id']);
//排除成交报告其它状态 //排除成交报告其它状态
if (empty($bargain_data['id'])) { if (empty($bargain_data['id'])) {
...@@ -1382,10 +1437,11 @@ class Finance extends Basic ...@@ -1382,10 +1437,11 @@ class Finance extends Basic
$m_partial = new OPartialCommission(); $m_partial = new OPartialCommission();
$check = new VipService(); $check = new VipService();
$m_report = new OReportModel();
$data = $this->params["commission_date"]; $data = $this->params["commission_date"];
$add_arr = $update_arr = $log_data = $real_income_id = $real_income_old = []; $add_arr = $update_arr = $log_data = $real_income_id = $real_income_old = [];
$i = $j = 0; $i = $j = $user_id = 0;
foreach ($data as $item) { foreach ($data as $item) {
if (!isset($item['practical_fee']) || !isset($item['cash']) || !isset($item['service_charge']) || if (!isset($item['practical_fee']) || !isset($item['cash']) || !isset($item['service_charge']) ||
!isset($item['charity_fund']) || !isset($item['real_fee'])) { !isset($item['charity_fund']) || !isset($item['real_fee'])) {
...@@ -1412,6 +1468,14 @@ class Finance extends Basic ...@@ -1412,6 +1468,14 @@ class Finance extends Basic
if (empty($partial_data['confirm_date'])) { if (empty($partial_data['confirm_date'])) {
$update_arr[$i]['confirm_date'] = date("Y-m-d H:i:s", time()); $update_arr[$i]['confirm_date'] = date("Y-m-d H:i:s", time());
$update_arr[$i]['confirm_status'] = 1; $update_arr[$i]['confirm_status'] = 1;
if (empty($user_id) && $item['report_id']) {
$user_id = $m_report->getFieldValue('user_id',['id'=>$item['report_id']]);
if ($user_id) {
$service = new ConvertCouponService();
$service->convertCoupon($user_id); //核销红包
}
}
} }
} }
$i++; $i++;
......
...@@ -86,6 +86,7 @@ class Basic extends Controller ...@@ -86,6 +86,7 @@ class Basic extends Controller
'index/saveActivity', 'index/saveActivity',
'index/getActivityList', 'index/getActivityList',
'index/checkReferrer', 'index/checkReferrer',
'index/getActivityCoupon',
); );
/** /**
......
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