|
|
@@ -13,12 +13,7 @@ namespace app\admin\controller;
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Db;
|
|
|
use think\db\Query;
|
|
|
-use app\admin\model\MarketModel;
|
|
|
-use app\weixin\model\AccountLog;
|
|
|
-use app\weixin\model\Market;
|
|
|
-use app\weixin\model\Member;
|
|
|
-use app\weixin\model\UserBalanceLog;
|
|
|
-
|
|
|
+use app\admin\model\BooksModel;
|
|
|
use app\weixin\model\Wechat;
|
|
|
use app\weixin\service\PRedis;
|
|
|
|
|
|
@@ -38,29 +33,13 @@ use app\weixin\service\PRedis;
|
|
|
class MarketController extends AdminBaseController
|
|
|
{
|
|
|
|
|
|
- //分销设置列表
|
|
|
- public function marketsetlist(){
|
|
|
-
|
|
|
- //查询得到分销表
|
|
|
- $marketlist=Db::name('market')
|
|
|
- ->order("updated_at DESC")
|
|
|
- ->paginate(15,false,['query'=>request()->param()]);
|
|
|
-
|
|
|
- // var_dump($market);die();
|
|
|
-
|
|
|
- $page = $marketlist->render();
|
|
|
- $this->assign('list', $marketlist);
|
|
|
- $this->assign('page', $page);
|
|
|
- return $this->fetch();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 分销设置界面
|
|
|
*/
|
|
|
public function marketset(){
|
|
|
|
|
|
//查询得到分销表
|
|
|
- $market=Db::name('market')->where(array('id'=> input('id')))->find();
|
|
|
+ $market=Db::name('market')->where('id',1)->find();
|
|
|
|
|
|
// var_dump($market);die();
|
|
|
$this->assign('market', $market);
|
|
|
@@ -75,31 +54,10 @@ class MarketController extends AdminBaseController
|
|
|
|
|
|
//提交 param('level_1'),也可以相当于param['level_1'];
|
|
|
$data=$this->request->param();
|
|
|
- $MarketModel = new MarketModel();
|
|
|
- $data['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
-
|
|
|
- if($MarketModel->allowField(true)->save($data)){
|
|
|
- $this->success('增加成功!',url("Market/marketsetlist"));
|
|
|
- }else{
|
|
|
- $this->error('增加失败!');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 分销设置面编辑
|
|
|
- */
|
|
|
- public function marketsetedit(){
|
|
|
-
|
|
|
- //提交 param('level_1'),也可以相当于param['level_1'];
|
|
|
- $data=$this->request->param();
|
|
|
- $MarketModel = new MarketModel();
|
|
|
$data['updated_at'] = date('Y-m-d H:i:s',time());
|
|
|
|
|
|
- if($MarketModel->allowField(true)->isUpdate(true)->save($data)){
|
|
|
- $this->success('保存成功!',url("Market/marketsetlist"));
|
|
|
-
|
|
|
+ if(Db::name('market')->where('id',1)->update($data)){
|
|
|
+ $this->success('保存成功!');
|
|
|
}else{
|
|
|
$this->error('保存失败!');
|
|
|
}
|
|
|
@@ -601,7 +559,161 @@ class MarketController extends AdminBaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ //显示子级用户显示
|
|
|
+ public function Markettwouser(){
|
|
|
+
|
|
|
+ $data = $this->request->param();
|
|
|
+ session('search',[
|
|
|
+ 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
|
|
|
+ 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
|
|
|
+ ]);
|
|
|
+ // 添加返回历史修改 by wesmiler 2020-02-16
|
|
|
+ $history = isset($data['history'])? intval($data['history']) : 0;
|
|
|
+ if($history){
|
|
|
+ $data = session('user_search');
|
|
|
+ }else{
|
|
|
+ session('user_search', $data);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改 end
|
|
|
+
|
|
|
+ //var_dump($data);die;
|
|
|
+ $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,last_login_time,up.idcard,
|
|
|
+ up.idcard_check,up.position_check,up.education_check')
|
|
|
+ ->alias('u')
|
|
|
+ ->join('user_profile up','u.id=up.userid','left')
|
|
|
+
|
|
|
+ ->where(function (Query $query) use($data){
|
|
|
+ $query->where('u.user_type', 2);
|
|
|
+ $query->where('u.openid', 'not in','');
|
|
|
+ $query->where('u.agent_type',1);
|
|
|
+
|
|
|
+ //代表是否付费定制
|
|
|
+ ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
|
|
|
+
|
|
|
+ //代表是否冻结
|
|
|
+ if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
|
|
|
+ ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //代表是否筛选
|
|
|
+ ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
|
|
|
+
|
|
|
+ //代表是否注销
|
|
|
+ if($this->request->action()!='userban' && $this->request->param('u')!=3){
|
|
|
+ ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //$data = $this->request->param();
|
|
|
+ if (!empty($data['uid'])) {
|
|
|
+ $query->where('u.id', intval($data['uid']));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($data['keyword'])) {
|
|
|
+ $keyword = $data['keyword'];
|
|
|
+ $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
|
|
|
+ }
|
|
|
+ //年龄区间查询
|
|
|
+ if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
|
|
|
+
|
|
|
+ $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
|
|
|
+ $query->whereNotNull('u.birthday');
|
|
|
+ }
|
|
|
+
|
|
|
+ // //只有第一个年龄的情况下
|
|
|
+ if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
|
|
|
+ $birthday = $data['age1'];
|
|
|
+ $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
|
|
|
+ }
|
|
|
+
|
|
|
+ // //只有第二个年龄的情况下
|
|
|
+ if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
|
|
|
+ $birthday = $data['age2'];
|
|
|
+ $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
|
|
|
+ }
|
|
|
+
|
|
|
+ //身高区间查询
|
|
|
+
|
|
|
+ if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
|
|
|
+
|
|
|
+ $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
|
|
|
+ }
|
|
|
+
|
|
|
+ //身高第一个查找
|
|
|
+ if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
|
|
|
+
|
|
|
+ $query->where('up.height',input('height'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //身高第二个查找
|
|
|
+ if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
|
|
|
+
|
|
|
+ $query->where('up.height',input('heightt'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //学历
|
|
|
+ if((!empty(input('education')) && input('education')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.education',input('education'));
|
|
|
+ }
|
|
|
+ //职位
|
|
|
+ if((!empty(input('occupation')) && input('occupation')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.occupation',input('occupation'));
|
|
|
+ }
|
|
|
+ //收入
|
|
|
+ if((!empty(input('salary')) && input('salary')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.salary',input('salary'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //资产
|
|
|
+ if((!empty(input('property')) && input('property')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.property',input('property'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //家乡
|
|
|
+ if((!empty(input('home_city')) && input('home_city')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
|
|
|
+ }
|
|
|
+ //居住地(市)
|
|
|
+
|
|
|
+ if((!empty(input('city')) && input('city')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.city','like','%'.input('city').'%');
|
|
|
+ }
|
|
|
+ //婚姻状况
|
|
|
+ if((!empty(input('married')) && input('married')!='none') ){
|
|
|
+
|
|
|
+ $query->where('up.married',input('married'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //性别
|
|
|
+ if((!empty(input('sex')) && input('sex')!='none') ){
|
|
|
+
|
|
|
+ $query->where('u.sex',input('sex'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ //待审核
|
|
|
+ ->order("u.create_time DESC")
|
|
|
+ ->paginate(10,false,['query'=>request()->param()]);
|
|
|
+ // echo Db::name('user')->getLastSql();die;
|
|
|
+ // 获取分页显示
|
|
|
+ $page = $list->render();
|
|
|
+ $this->assign('list', $list);
|
|
|
+ $this->assign('page', $page);
|
|
|
+
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -617,115 +729,33 @@ class MarketController extends AdminBaseController
|
|
|
* 审核通过和审核不通过的弹框操作
|
|
|
*/
|
|
|
public function doconfrom(){
|
|
|
-
|
|
|
$param= $this->request->param();
|
|
|
- $where = ['id' => $param['id'], 'agent_type' => 1, 'agent_status' => 1];
|
|
|
- $field = 'id,openid,user_nickname,parent_id,user_login,balance';
|
|
|
- $userInfo = Member::getInfo($where, $field);
|
|
|
|
|
|
if(isset($param['yes']) && isset($param['id'])){
|
|
|
//开始进行调用成功发送
|
|
|
|
|
|
- $data['agent_status'] = 3;
|
|
|
- $data['agent_type'] = 2;
|
|
|
+ $data['agent_status'] = 1;
|
|
|
$result=Db::name('user')->where('id',$param['id'])->update($data);
|
|
|
|
|
|
+ // echo Db::name('user')->getLastSql();die();
|
|
|
+ //$result=Activity::bookConfirm($param['id'],3);
|
|
|
+ // if(is_array($result)){
|
|
|
if($result){
|
|
|
-
|
|
|
- //顺便进行,模板发送。
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
- if($openid){
|
|
|
- $checkTime = date('Y.m.d H:i');
|
|
|
- $remark = "感谢您对拾光的信任,我们一起解救单身青年!";
|
|
|
- $msgParams = [
|
|
|
- 'title' => "您的分销员申请已审核通过,感谢你的注册申请!",
|
|
|
- 'remark' => $remark,
|
|
|
- 'type' => 'confirm',
|
|
|
- 'keywords' => [
|
|
|
- 'keyword1' => [
|
|
|
- 'value' => "已审核通过!",
|
|
|
- 'color' => '#3fad46',
|
|
|
- ],
|
|
|
- 'keyword2' => [
|
|
|
- 'value' => $checkTime,
|
|
|
- 'color' => '#173177',
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'url' => url('/weixin/market/confirm', '', '', true),
|
|
|
- ];
|
|
|
-
|
|
|
- Wechat::sendTplMsg($openid, $msgParams);
|
|
|
- }
|
|
|
-
|
|
|
echo 1;die;
|
|
|
}else{
|
|
|
- //顺便进行,模板发送。
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
- if($openid){
|
|
|
- $checkTime = date('Y.m.d H:i');
|
|
|
- $remark = "";
|
|
|
- $msgParams = [
|
|
|
- 'title' => "您的分销员审核失败!",
|
|
|
- 'remark' => $remark,
|
|
|
- 'type' => 'confirm',
|
|
|
- 'keywords' => [
|
|
|
- 'keyword1' => [
|
|
|
- 'value' => "审核失败!",
|
|
|
- 'color' => '#d61712',
|
|
|
- ],
|
|
|
- 'keyword2' => [
|
|
|
- 'value' => $checkTime,
|
|
|
- 'color' => '#173177',
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'url' => url('/weixin/market/confirm', '', '', true),
|
|
|
- ];
|
|
|
-
|
|
|
- Wechat::sendTplMsg($openid, $msgParams);
|
|
|
- }
|
|
|
-
|
|
|
echo 0;die;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(isset($param['no']) && isset($param['id'])){
|
|
|
//开始进行调用审核失败发送
|
|
|
- $data['agent_status'] = 3;
|
|
|
- $data['agent_type'] = 2;
|
|
|
- $result=Db::name('user')->where('id',$param['id'])->update($data);
|
|
|
-
|
|
|
- if($result){
|
|
|
- //顺便进行,模板发送。
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
- if($openid){
|
|
|
- $checkTime = date('Y.m.d H:i');
|
|
|
- $remark = input('noremark');
|
|
|
- $msgParams = [
|
|
|
- 'title' => "您的分销员审核失败!",
|
|
|
- 'remark' => $remark,
|
|
|
- 'type' => 'confirm',
|
|
|
- 'keywords' => [
|
|
|
- 'keyword1' => [
|
|
|
- 'value' => "审核失败!",
|
|
|
- 'color' => '#d61712',
|
|
|
- ],
|
|
|
- 'keyword2' => [
|
|
|
- 'value' => $checkTime,
|
|
|
- 'color' => '#173177',
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'url' => url('/weixin/market/confirm', '', '', true),
|
|
|
- ];
|
|
|
-
|
|
|
- Wechat::sendTplMsg($openid, $msgParams);
|
|
|
- }
|
|
|
- echo 1;die;
|
|
|
|
|
|
+ // $result=Activity::bookConfirm($param['id'],5,$param['noremark']);
|
|
|
+ if(is_array($result)){
|
|
|
+ echo 1;die;
|
|
|
}else{
|
|
|
- echo 0;die;
|
|
|
+ echo 0;die;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -801,13 +831,10 @@ class MarketController extends AdminBaseController
|
|
|
}
|
|
|
|
|
|
})
|
|
|
- ->field('blog.*,u.user_nickname,u.real_name')
|
|
|
+ ->field('blog.*,u.user_nickname')
|
|
|
->find();
|
|
|
-
|
|
|
-
|
|
|
- $source_username= Db::name('user')->where(['id'=> $balance_log['source_uid'], 'user_type'=> 2])->field('user_nickname')->find();
|
|
|
|
|
|
- $this->assign('source_username',$source_username['user_nickname']);
|
|
|
+
|
|
|
$this->assign($balance_log);
|
|
|
return $this->fetch();
|
|
|
|
|
|
@@ -907,70 +934,66 @@ class MarketController extends AdminBaseController
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 后台进行奖励充值
|
|
|
+ * 进行奖励充值
|
|
|
*/
|
|
|
|
|
|
public function markettoreward(){
|
|
|
|
|
|
-
|
|
|
- $where = ['id' => input('id'), 'agent_type' => 1, 'agent_status' => 1];
|
|
|
-
|
|
|
- $field = 'id,openid,user_nickname,parent_id,user_login,balance';
|
|
|
- $userInfo = Member::getInfo($where, $field);
|
|
|
|
|
|
- $nickname = isset($userInfo['nickname']) ? trim($userInfo['nickname']) : '';
|
|
|
- $userLogin = isset($userInfo['user_login']) ? trim($userInfo['user_login']) : '';
|
|
|
- $balance = isset($userInfo['balance']) ? floatval($userInfo['balance']) : 0;
|
|
|
- $awardMoney = input('am');
|
|
|
- $rm = input('ar');
|
|
|
- $userId = input('id');
|
|
|
+ $this->assign("id",input('id'));
|
|
|
|
|
|
- // 账户变动
|
|
|
- Db::startTrans();
|
|
|
- if (Member::where($where)->setInc('balance', input('am'))) {
|
|
|
- // 写入奖励日志
|
|
|
+ $level2Award = isset($marketConfig['level_2']) ? floatval($marketConfig['level_2']) : 0;
|
|
|
+ $awardMoneyTwo = $marketType==1? moneyFormat($level2Award) : moneyFormat($money * ($level2Award / 100));
|
|
|
|
|
|
- $logTitle = "后台为你进行了{$rm},奖励额度为:{$awardMoney}元";
|
|
|
+ $logData['levelAward'] = $level2Award;
|
|
|
+ if ($level2Award > 0 && $level2Award <= 100 && $awardMoneyTwo > 0) {
|
|
|
+ // 账户变动
|
|
|
+ Db::startTrans();
|
|
|
+ if (Member::where($whereTwo)->setInc('balance', $awardMoneyTwo)) {
|
|
|
+ // 写入奖励日志
|
|
|
+ $levelName = "您的下级[{$nickname}]邀请的[{$sourceNickname}]用户";
|
|
|
+ $marketName = isset($marketConfig['name']) ? $marketConfig['name'] : '分销收益';
|
|
|
+ $logTitle = "{$levelName}消费{$money}元,获得{$marketName}{$awardMoneyTwo}元";
|
|
|
$log = [
|
|
|
- 'change' => $awardMoney,
|
|
|
- 'type' => 31, //平台奖励
|
|
|
- 'level' => 1,
|
|
|
+ 'change' => $awardMoneyTwo,
|
|
|
+ 'type' => $type,
|
|
|
+ 'level' => 2,
|
|
|
'change_type' => 1,
|
|
|
- 'pay_money' => $awardMoney,
|
|
|
- 'user_id' => $userId,
|
|
|
- 'source_uid' => '',
|
|
|
- 'balance' => moneyFormat($balance + $awardMoney),
|
|
|
+ 'pay_money' => $awardMoneyTwo,
|
|
|
+ 'user_id' => $userTwoId,
|
|
|
+ 'source_uid' => $userId,
|
|
|
+ 'balance' => moneyFormat($balanceTwo + $awardMoneyTwo),
|
|
|
'description' => $logTitle,
|
|
|
'create_time' => time(),
|
|
|
'status' => 1,
|
|
|
];
|
|
|
-
|
|
|
+ $logData['log'] = $log;
|
|
|
+ PRedis::set("{$cacheKey}:log", $logData, 7200);
|
|
|
if(UserBalanceLog::insertGetId($log)){
|
|
|
-
|
|
|
- // 账户明细
|
|
|
+ // 账户明细
|
|
|
$accountData = [
|
|
|
'type' => 4,
|
|
|
'account_type' => 2,
|
|
|
'change_type' => 1,
|
|
|
- 'user_id' => $userId,
|
|
|
- 'money' => $awardMoney,
|
|
|
- 'balance' => $balance,
|
|
|
+ 'user_id' => $userTwoId,
|
|
|
+ 'money' => $awardMoneyTwo,
|
|
|
+ 'balance' => $balanceTwo,
|
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
|
'remark' => $logTitle,
|
|
|
];
|
|
|
if(AccountLog::insertGetId($accountData)){
|
|
|
// 发送模板消息
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
+ $openid = isset($userInfoTwo['openid'])? $userInfoTwo['openid'] : '';
|
|
|
if($openid){
|
|
|
$checkTime = date('Y.m.d H:i');
|
|
|
$remark = "感谢您对拾光的信任,我们一起解救单身青年!点击查看收益明细";
|
|
|
$msgParams = [
|
|
|
- 'title' => "管理员后台为你奖励的收益已到账!\n\n类型:\t{$rm}",
|
|
|
+ 'title' => "您的下级[$nickname]邀请的用户[{$sourceNickname}]消费所得的收益已到账!\n\n类型:\t{$marketName}",
|
|
|
'remark' => $remark,
|
|
|
'type' => 'income',
|
|
|
'keywords' => [
|
|
|
'keyword1' => [
|
|
|
- 'value' => "{$awardMoney}",
|
|
|
+ 'value' => "{$awardMoneyTwo}",
|
|
|
'color' => '#173177',
|
|
|
],
|
|
|
'keyword2' => [
|
|
|
@@ -980,29 +1003,33 @@ class MarketController extends AdminBaseController
|
|
|
],
|
|
|
'url' => url('/weixin/market/income', '', '', true),
|
|
|
];
|
|
|
- // PRedis::set("{$cacheKey}:message", ['result' => $userInfo, 'params' => $msgParams], 600);
|
|
|
+ PRedis::set("{$cacheKey}:message", ['result' => $userInfoTwo, 'params' => $msgParams], 600);
|
|
|
Wechat::sendTplMsg($openid, $msgParams);
|
|
|
}
|
|
|
|
|
|
- Db::commit();;
|
|
|
+ Db::commit();
|
|
|
}else{
|
|
|
- //PRedis::set("{$cacheKey}:account_log", $logData, 7200);
|
|
|
+ PRedis::set("{$cacheKey}:account_log", $logData, 7200);
|
|
|
Db::rollback();
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
-
|
|
|
- Db::rollback();
|
|
|
+ PRedis::set("{$cacheKey}:balance_log", $logData, 7200);
|
|
|
+ Db::rollback();
|
|
|
+ return false;
|
|
|
}
|
|
|
- }else{
|
|
|
- Db::rollback();
|
|
|
- echo 0;die();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+ } else {
|
|
|
+ PRedis::set("{$cacheKey}:update_balance", $logData, 7200);
|
|
|
+ Db::rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ PRedis::set("{$cacheKey}:error_awardMoney", $logData, 7200);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- echo 1;die();
|
|
|
+ return $this->fetch();
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1066,6 +1093,7 @@ class MarketController extends AdminBaseController
|
|
|
//提现审核确认显示
|
|
|
public function godrawconfrom(){
|
|
|
$this->assign('id',input('id'));
|
|
|
+ $this->assign('balance',input('balance'));
|
|
|
return $this->fetch("marketdrawconfrom");
|
|
|
|
|
|
}
|
|
|
@@ -1073,16 +1101,17 @@ class MarketController extends AdminBaseController
|
|
|
//进行提交审核提现。
|
|
|
public function dodrawconfrom(){
|
|
|
$param= $this->request->param();
|
|
|
-
|
|
|
+
|
|
|
if(isset($param['yes']) && isset($param['id'])){
|
|
|
|
|
|
+ //
|
|
|
+
|
|
|
//通过userid来得到openid
|
|
|
$result=Db::name('user_balance_log')
|
|
|
->alias('ub')
|
|
|
->join('user u','ub.user_id=u.id','left')
|
|
|
- ->where(['ub.id'=>$param['id'],'ub.type'=>1])
|
|
|
-
|
|
|
- ->field('ub.order_sn,ub.description,ub.user_id,ub.pay_money,ub.change,u.openid')
|
|
|
+ ->where(['ub.id'=>$param['id']])
|
|
|
+ ->field('ub.order_sn,ub.description,ub.user_id,ub.pay_money,ub.change,u.openid,ub.create_time')
|
|
|
->find();
|
|
|
|
|
|
|
|
|
@@ -1090,72 +1119,90 @@ class MarketController extends AdminBaseController
|
|
|
echo 0;die;
|
|
|
}
|
|
|
|
|
|
- // 账户明细
|
|
|
- $accountData = [
|
|
|
- 'type' => 4,
|
|
|
- 'account_type' => 2,
|
|
|
- 'change_type' => 1,
|
|
|
- 'user_id' => $param['id'],
|
|
|
- 'money' =>$result['pay_money'],
|
|
|
- 'balance' =>$result['change'],
|
|
|
- 'created_at' => date('Y-m-d H:i:s'),
|
|
|
- 'remark' => $param['noremark'],
|
|
|
- ];
|
|
|
-
|
|
|
- //插入user_account_log表
|
|
|
- if(AccountLog::insertGetId($accountData)){
|
|
|
-
|
|
|
//开始进行调用成功发送
|
|
|
$order = array(
|
|
|
|
|
|
- 'orderNo' => $result['order_sn'], //订单号
|
|
|
+ 'orderNo' => $result['order_sn'], //订单号
|
|
|
'openid' => $result['openid'],
|
|
|
- 'amount' => $result['pay_money'], //实际支付金额
|
|
|
+ 'amount' => $result['pay_money'], //实际支付金额
|
|
|
'desc' =>$result['description'], //描述
|
|
|
|
|
|
);
|
|
|
- //进行,变更审核成功。
|
|
|
- $data0['status'] = 2;
|
|
|
- $result=Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
|
|
|
- if($result){
|
|
|
- $resulttrans=wechat::transferOrder($order);
|
|
|
- if($resulttrans['result_code']=="SUCCESS"){
|
|
|
-
|
|
|
- // 发送模板消息
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
- if($openid){
|
|
|
- $checkTime = date('Y.m.d H:i');
|
|
|
- $remark = "感谢您对拾光的信任,我们一起解救单身青年!点击查看收益明细";
|
|
|
- $msgParams = [
|
|
|
- 'title' => "提现到账!",
|
|
|
- 'remark' => $remark,
|
|
|
- 'type' => 'income',
|
|
|
- 'keywords' => [
|
|
|
- 'keyword1' => [
|
|
|
- 'value' => "{$awardMoney}",
|
|
|
- 'color' => '#173177',
|
|
|
+
|
|
|
+ $resulttrans=wechat::transferOrder($order); //进行调用发送企业到零钱打款模板信息
|
|
|
+ if($resulttrans['result_code']=="SUCCESS"){
|
|
|
+
|
|
|
+ // 增加账户明细
|
|
|
+ $accountData = [
|
|
|
+ 'type' => 8,
|
|
|
+ 'account_type' => 2,
|
|
|
+ 'change_type' => 2,
|
|
|
+ 'user_id' => $param['id'],
|
|
|
+ 'money' => (param('pay_money')!='')?param('pay_money'):$result['pay_money'],
|
|
|
+ 'balance' => $param['balance'],
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'remark' => '客户进行提现',
|
|
|
+ ];
|
|
|
+ Db::startTrans();
|
|
|
+ if(AccountLog::insertGetId($accountData)){
|
|
|
+ //进行,变更审核成功。
|
|
|
+ $data0['status'] = 2;
|
|
|
+ $result0=Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
|
|
|
+ if($result0){
|
|
|
+ //发送模板消息
|
|
|
+ if($result['openid']){
|
|
|
+ $checkTime = date('Y-M-d H:i:s',$result['create_time']);
|
|
|
+ $giveTime = date('Y-M-d H:i:s',time());
|
|
|
+ $remark = "您的提现已到账,请查收!";
|
|
|
+ $msgParams=[
|
|
|
+ 'title'=>$remark,
|
|
|
+ 'remark'=>$remark,
|
|
|
+ 'type' =>'withdraw',
|
|
|
+ 'keywords' =>[
|
|
|
+ 'keyword1'=>[
|
|
|
+ 'value'=> $param['balance'],
|
|
|
+ 'color'=>'#173177'
|
|
|
],
|
|
|
- 'keyword2' => [
|
|
|
- 'value' => $checkTime,
|
|
|
- 'color' => '#173177',
|
|
|
+ 'keyword2'=>[
|
|
|
+ 'value'=>$checkTime,
|
|
|
+ 'color'=>'#173177'
|
|
|
+ ],
|
|
|
+ 'keyword3'=>[
|
|
|
+ 'value'=>'微信账户类型',
|
|
|
+ 'color'=>'#173177'
|
|
|
+ ],
|
|
|
+ 'keyword4'=>[
|
|
|
+ 'value'=>$giveTime,
|
|
|
+ 'color'=>'#173177'
|
|
|
],
|
|
|
+ 'keyword5'=>[
|
|
|
+ 'value'=>$result['order_sn'],
|
|
|
+ 'color'=>'#173177',
|
|
|
+ ]
|
|
|
],
|
|
|
- 'url' => url('/weixin/market/income', '', '', true),
|
|
|
+ 'url' =>url('/weixin/Account/withdraw','','',true),
|
|
|
+
|
|
|
];
|
|
|
- // PRedis::set("{$cacheKey}:message", ['result' => $userInfo, 'params' => $msgParams], 600);
|
|
|
- Wechat::sendTplMsg($openid, $msgParams);
|
|
|
+
|
|
|
+ wechat::sendTplMsg($result['openid'],$msgParams);
|
|
|
+
|
|
|
}
|
|
|
- echo 1;die;
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ echo 1;die;
|
|
|
}else{
|
|
|
- echo 0;die;
|
|
|
+ Db::rollback();
|
|
|
+ echo 0;die;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
- echo 0;die;
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ echo 0;die();
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ echo 0;die;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1171,33 +1218,8 @@ class MarketController extends AdminBaseController
|
|
|
//进行反扣回去
|
|
|
$data0['balance'] +=$result['change'];
|
|
|
Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
|
|
|
-
|
|
|
Db::name('user')->where('id',$result['user_id'])->update($data0);
|
|
|
|
|
|
- // 发送模板消息
|
|
|
- $openid = isset($userInfo['openid'])? $userInfo['openid'] : '';
|
|
|
- if($openid){
|
|
|
- $checkTime = date('Y.m.d H:i');
|
|
|
- $remark = "感谢您对拾光的信任,我们一起解救单身青年!点击查看收益明细";
|
|
|
- $msgParams = [
|
|
|
- 'title' => "提现失败!",
|
|
|
- 'remark' => $remark,
|
|
|
- 'type' => 'income',
|
|
|
- 'keywords' => [
|
|
|
- 'keyword1' => [
|
|
|
- 'value' => "{$awardMoney}",
|
|
|
- 'color' => '#173177',
|
|
|
- ],
|
|
|
- 'keyword2' => [
|
|
|
- 'value' => $checkTime,
|
|
|
- 'color' => '#173177',
|
|
|
- ],
|
|
|
- ],
|
|
|
- 'url' => url('/weixin/market/income', '', '', true),
|
|
|
- ];
|
|
|
- // PRedis::set("{$cacheKey}:message", ['result' => $userInfo, 'params' => $msgParams], 600);
|
|
|
- Wechat::sendTplMsg($openid, $msgParams);
|
|
|
- }
|
|
|
echo 0;die;
|
|
|
}
|
|
|
}
|
|
|
@@ -1212,73 +1234,10 @@ class MarketController extends AdminBaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
- //显示分销员提现记录
|
|
|
- public function withdrawrecord(){
|
|
|
|
|
|
- $data = $this->request->param();
|
|
|
- session('search',[
|
|
|
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
|
|
|
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
|
|
|
- ]);
|
|
|
- // 添加返回历史修改 by wesmiler 2020-02-16
|
|
|
- $history = isset($data['history'])? intval($data['history']) : 0;
|
|
|
- if($history){
|
|
|
- $data = session('user_search');
|
|
|
- }else{
|
|
|
- session('user_search', $data);
|
|
|
- }
|
|
|
|
|
|
- // 修改 end
|
|
|
|
|
|
- $list = Db::name('user_balance_log')
|
|
|
|
|
|
- ->alias('ub')
|
|
|
- ->join('user u','u.id = ub.user_id','left')
|
|
|
- ->where(function (Query $query) use($data){
|
|
|
-
|
|
|
- $query->where('ub.type', 1);
|
|
|
- $query->where('ub.status',2); //已审核
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- ->field('ub.*,u.user_nickname,u.real_name')
|
|
|
-
|
|
|
- //待审核
|
|
|
- ->order("ub.create_time DESC")
|
|
|
- ->paginate(10,false,['query'=>request()->param()])
|
|
|
- ->each(function($item,$key){
|
|
|
-
|
|
|
- $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('real_name,user_nickname')->find();
|
|
|
-
|
|
|
- return $item;
|
|
|
-
|
|
|
- })
|
|
|
- ;
|
|
|
- //echo Db::name('user')->getLastSql();die;
|
|
|
- // 获取分页显示
|
|
|
- $page = $list->render();
|
|
|
- $this->assign('list', $list);
|
|
|
- $this->assign('page', $page);
|
|
|
-
|
|
|
- return $this->fetch('marketwithdraw');
|
|
|
- }
|
|
|
-
|
|
|
- //删除分销设置
|
|
|
-
|
|
|
- public function deleteset(){
|
|
|
-
|
|
|
- $param = $this->request->param();
|
|
|
-
|
|
|
- if (isset($param['ids']) && isset($param["yes"])) {
|
|
|
- $ids = $this->request->param('ids/a');
|
|
|
-
|
|
|
- Db::name('market')->where('id', 'in', $ids)->update(['status' => 2]);
|
|
|
-
|
|
|
- $this->success("活动删除成功!", '');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
|
|
|
|