优化单笔打款

master
chenzhi 3 years ago
parent f35efd9e16
commit ef8444bcba

@ -41,16 +41,36 @@ class WxPaymentController extends BaseController
$params = I('get.'); $params = I('get.');
$page = $params['p'] ? intval($params['p']) : 1; $page = $params['p'] ? intval($params['p']) : 1;
$row = $params['row'] ? intval($params['row']) : 10; $row = $params['row'] ? intval($params['row']) : 10;
$where = []; $where = [
'_string'=>'1=1'
];
if(isset($_REQUEST['nickname'])){ if(isset($_REQUEST['nickname'])){
$where['nickname'] = ["LIKE","%{$_REQUEST['nickname']}%"]; $where['nickname'] = ["LIKE","%{$_REQUEST['nickname']}%"];
} }
if(isset($_REQUEST['realname'])){
$where['realname'] = ["LIKE","%{$_REQUEST['realname']}%"];
}
if(isset($_REQUEST['type'])){
if($_REQUEST['type'] == 1){
$where['_string'] .= " AND realname = ''";
}
if($_REQUEST['type'] == 2){
$where['_string'] .= " AND realname != ''";
}
}
$data = M('mini_program_user', 'tab_') $data = M('mini_program_user', 'tab_')
->field("wx_json",true) ->field("wx_json",true)
->where($where) ->where($where)
->page($page,$row) ->page($page,$row)
->select(); ->select();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if(empty($value['realname'])){
$data[$key]['is_pay'] =0;
}else{
$data[$key]['is_pay'] =1;
}
$data[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']); $data[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']);
} }
$count = M('mini_program_user', 'tab_')->where($where)->count(); $count = M('mini_program_user', 'tab_')->where($where)->count();
@ -61,6 +81,26 @@ class WxPaymentController extends BaseController
$this->assign('data', $data); $this->assign('data', $data);
$this->display(); $this->display();
} }
public function updateRealname()
{
$params = I('post.');
M('mini_program_user', 'tab_')->save([
'id'=>$params['id'],
'realname'=>trim($params['realname'])
]);
$this->ajaxReturn([
'success'=>'ok'
]);
}
public function addPayList()
{
$params = I('post.');
$batch = date('Ymd').date('His').sp_random_num(3);
$item = M('mini_program_user',"tab_")->field('realname,openid')->where(['id'=>$params['id']])->find();
$item['statement_money'] = $params['statement_money'];
$this->addListItem($batch,$item);
$this->ajaxReturn(["status"=>1,"msg"=>"添加成功"]);
}
public function customerExport() public function customerExport()
{ {
@ -90,7 +130,7 @@ class WxPaymentController extends BaseController
$line = 2; $line = 2;
//设置模板文件 //设置模板文件
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $line-1)->setCellValue('B'.$line, $value['openid']); $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $line-1)->setCellValue('B'.$line, $value['openid'])->setCellValue('C'.$line, $value['realname']);
$line++; $line++;
} }
@ -199,36 +239,41 @@ class WxPaymentController extends BaseController
if(count($checkarr) < 1){ if(count($checkarr) < 1){
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]); $this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
} }
foreach ($checkarr as $k => &$v) {
$this->addListItem($batch,$v);
}
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
}
private function addListItem($batch,$v)
{
$pinyin = new \Think\Pinyin(); $pinyin = new \Think\Pinyin();
$wxPayment = M('wx_payment',"tab_"); $wxPayment = M('wx_payment',"tab_");
foreach ($checkarr as $k => &$v) {
if(!isset($v['realname']) || !isset($v['openid']) || !isset($v['statement_money']) || $v['realname'] == '' || $v['openid'] == '' || $v['statement_money'] <= 0){ if(!isset($v['realname']) || !isset($v['openid']) || !isset($v['statement_money']) || $v['realname'] == '' || $v['openid'] == '' || $v['statement_money'] <= 0){
$wxPayment->where("batch_num = '{$v['batch_num']}'")->delete(); $wxPayment->where("batch_num = '{$batch}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"真实姓名,openid,打款金额均不允许为空"]); $this->ajaxReturn(["status"=>0,"msg"=>"真实姓名,openid,打款金额均不允许为空"]);
} }
$num = mb_strlen($v['realname'], 'UTF8'); $num = mb_strlen($v['realname'], 'UTF8');
$short = ''; $short = '';
for ($i = 0; $i < $num; $i++) { for ($i = 0; $i < $num; $i++) {
$str = mb_substr($v['realname'], $i, $i + 1, 'UTF8'); $str = mb_substr($v['realname'], $i, $i + 1, 'UTF8');
$short .= $pinyin->getFirstChar($str); $short .= $pinyin->getFirstChar($str);
} }
$v['batch_num'] = $batch; $v['batch_num'] = $batch;
$v['statement_num'] = "WX{$short}".date('Ymd').date('His').sp_random_string(5); $v['statement_num'] = "WX{$short}".date('Ymd').date('His').sp_random_string(5);
$v['create_time'] = time(); $v['create_time'] = time();
$res = $wxPayment->add($v); $res = $wxPayment->add($v);
if($res === false){ if($res === false){
$wxPayment->where("batch_num = '{$v['batch_num']}'")->delete(); $wxPayment->where("batch_num = '{$batch}'")->delete();
$this->ajaxReturn(["status"=>0,"msg"=>"添加失败"]); $this->ajaxReturn(["status"=>0,"msg"=>"添加失败"]);
}
} }
$this->ajaxReturn(["status"=>1,"msg"=>"ok"]);
} }
public function showPayment() public function showPayment()
{ {
if(!isset($_REQUEST['ids'])) $this->error("参数错误"); if(!isset($_REQUEST['ids'])) $this->error("参数错误");

@ -181,7 +181,7 @@
<script type="text/javascript"> <script type="text/javascript">
var isfile = false; var isfile = false;
var rABS = false; //是否将文件读取为二进制字符串 var rABS = false; //是否将文件读取为二进制字符串
var check_size = 1;//每次验证的数量 var check_size = 5;//每次验证的数量
var batch = '{$batch}'; var batch = '{$batch}';
var sendDefaultData = { var sendDefaultData = {
"filedata_count": 0, "filedata_count": 0,

@ -142,6 +142,18 @@
<input type="text" name="nickname" class="" value="{:I('nickname')}" placeholder="昵称查找" style="width: 180px;"/> <input type="text" name="nickname" class="" value="{:I('nickname')}" placeholder="昵称查找" style="width: 180px;"/>
</div> </div>
<div class="input-list">
<input type="text" name="realname" class="" value="{:I('realname')}" placeholder="真实姓名查找" style="width: 180px;"/>
</div>
<div class="input-list input-list-promote search_label_rehab">
<select id="type" name="type" class="select_gallery" style="width:150px;">
<option value="">是否实名</option>
<option value="1" <if condition="1 eq $_GET['type']">selected=selected</if>>未实名</option>
<option value="2" <if condition="2 eq $_GET['type']">selected=selected</if>>已实名</option>
</select>
</div>
<div class="input-list"> <div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('customerLists','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a> <a class="sch-btn" href="javascript:;" id="search" url="{:U('customerLists','model='.$model['name'] .'&row='.I('row'),false)}">搜索</a>
</div> </div>
@ -163,10 +175,12 @@
<thead> <thead>
<tr> <tr>
<th><input class="check-all" type="checkbox"></th> <th><input class="check-all" type="checkbox"></th>
<th>昵称</th>
<th>openid</th> <th>openid</th>
<th>真实姓名</th>
<th>昵称</th>
<th>头像</th> <th>头像</th>
<th>添加时间</th> <th>添加时间</th>
<th>操作</th>
</tr> </tr>
</thead> </thead>
@ -181,10 +195,17 @@
<volist name="data" id="data"> <volist name="data" id="data">
<tr> <tr>
<td ><input class="ids" type="checkbox" value="{$data['ids']}" data-verify_id="{$data['id']}" name="ids[]"></td> <td ><input class="ids" type="checkbox" value="{$data['ids']}" data-verify_id="{$data['id']}" name="ids[]"></td>
<td>{$data.nickname}</td>
<td>{$data.openid}</td> <td>{$data.openid}</td>
<td>{$data.realname}</td>
<td>{$data.nickname}</td>
<td style="display: flex;justify-content:center"><img src="{$data.avatar}" style="width: 50px;height: auto;"></td> <td style="display: flex;justify-content:center"><img src="{$data.avatar}" style="width: 50px;height: auto;"></td>
<td>{$data.create_time}</td> <td>{$data.create_time}</td>
<td>
<a class="edit" data-id="{$data['id']}" data-realname="{$data.realname}">编辑</a>
<if condition="$data.is_pay eq 1 ">
<a class="pay" data-id="{$data['id']}" data-realname="{$data.realname}">打款</a>
</if>
</td>
</tr> </tr>
</volist> </volist>
</notemtpy> </notemtpy>
@ -193,6 +214,44 @@
</div> </div>
</div> </div>
<script type="text/html" id="updateRealnameTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
小程序用户实名修改
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:80px;">真实姓名:</td>
<td class="r table_radio">
<input type="text" id="realname" name="realname" autocomplete="off" placeholder="请输入真实姓名" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="updateStatementSubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
<script type="text/html" id="payTpl">
<div style="padding:10px 40px 30px;">
<spend style="font-size:14px;color:#666;">
打款金额设置(单位元)
</spend>
<table border="0" cellspacing="0" cellpadding="0" style="margin-top:30px;">
<tr>
<td class="l noticeinfo" style="width:80px;">打款金额:</td>
<td class="r table_radio">
<input type="number" οninput="value=value.replace(/[^\w\.\/]/ig, '')" id="statement_money" name="statement_money" autocomplete="off" placeholder="请输入打款金额" />
</td>
</tr>
</table>
<button class="submit_btn mlspacing" id="paySubmit" type="submit" style="margin-top:30px;">
保存
</button>
</div>
</script>
<div class="page"> <div class="page">
{$_page|default=''} {$_page|default=''}
</div> </div>
@ -222,6 +281,86 @@
highlight_subnav("{:U('customerLists')}"); highlight_subnav("{:U('customerLists')}");
$(function(){ $(function(){
$(".edit").on("click",function(){
var html = $("#updateRealnameTpl").html();
var orginData = $(this).data();
layer.open({
type: 1,
title: "编辑",
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:function(){
$("#realname").val(orginData.realname);
$("#updateStatementSubmit").off("click");
$("#updateStatementSubmit").on("click",function() {
var realname= $("#realname").val();
$.ajax({
type: 'post',
url: "{:U('updateRealname')}",
data:{realname:realname,id:orginData.id},
success: function(data) {
if(data.success){
layer.alert('修改成功',function(){
window.location.reload();
});
}else{
layer.alert('修改失败');
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
}
});
})
$(".pay").on("click",function(){
var html = $("#payTpl").html();
var orginData = $(this).data();
layer.open({
type: 1,
title:'向【'+orginData.realname+'】打款',
maxWidth:720,
closeBtn: 1,
shadeClose: true,
content: html,
success:function(){
$("#statement_money").val(0);
$("#paySubmit").off("click");
$("#paySubmit").on("click",function() {
var statement_money= $("#statement_money").val();
$.ajax({
type: 'post',
url: "{:U('addPayList')}",
data:{statement_money:statement_money,id:orginData.id},
success: function(data) {
if(data.status ==1){
layer.alert('添加成功',function(){
window.location.href = "{:U('lists')}";
});
}else{
layer.alert(data.msg);
}
},
error:function(){
layer.alert("网络错误或超时");
return false;
}
});
});
}
});
})
$("#customerExport").click(function () { $("#customerExport").click(function () {
var flag = false; var flag = false;
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {

Loading…
Cancel
Save