This commit is contained in:
彭桃 2023-04-10 17:38:49 +08:00
parent 45e9f2810d
commit 9565792609
9 changed files with 1094 additions and 25 deletions

View File

@ -429,8 +429,8 @@ class StoreProduct extends BaseController
add_log('buy', $id, $param);
$app = $this->payment();
$total_fee = env('APP_DEBUG') ? 1 : $post_price;
// $total_fee = $post_price;
// $total_fee = env('APP_DEBUG') ? 1 : $post_price;
$total_fee = $post_price;
// 用 easywechat 封装的方法请求微信的统一下单接口
$result = $app->order->unify([
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
@ -520,6 +520,9 @@ class StoreProduct extends BaseController
return $product;
}
})
->withAttr('name',function ($value,$data){
return Db::table('cms_admin')->where('id','=',$data['admin_id'])->value('nickname');
})
->where($where)
->order('a.id desc,a.paid_at desc')
->paginate($rows, false, ['query' => $param]);
@ -559,6 +562,9 @@ class StoreProduct extends BaseController
->withAttr('status',function ($value,$data){
return 0;
})
->withAttr('name',function ($value,$data){
return Db::table('cms_admin')->where('id','=',$data['admin_id'])->value('nickname');
})
->where($where)
->whereNull('result_code')
->whereNull('return_code')
@ -675,6 +681,7 @@ class StoreProduct extends BaseController
$where[] = ['a.is_pay','=',0];
$where[] = ['a.is_del','=',0];
$where[] = ['a.is_fail','=',0];
$where[] = ['a.is_save','=',0];
if (isset($param['keywords']) && !empty($param['keywords'])){
$where[]=['b.nickname','like','%'.$param['keywords'].'%'];
}
@ -701,6 +708,8 @@ class StoreProduct extends BaseController
public function paycar(){
$param = get_params();
$id = $param['cart_id'];
Db::startTrans();//开启事务
$return = [];
if($id){
if(strpos($id,',')){ //多选购物车
@ -722,14 +731,20 @@ class StoreProduct extends BaseController
if (empty($store_product)) {
return to_assign(0,'查询的数据不存在');
}
$product[$k] = $store_product;
$product[$k]['number'] = $cart['cart_num'];
// 判断库存
if($store_product['stock'] < $number){
return to_assign(0,'超过库存数量');
}
$number += $cart['cart_num'];
$post_price = bcadd($post_price,bcmul(bcmul((string)$store_product['price'],(string)$number),'100'));
// 删除购物车
Db::table('cms_store_cart')->where($where)->update(['is_save'=>'1']);
}
$return['number'] = $number;
$ss[] = ['product_id','in',$ids];
$return['product'] = $product;
}else{
// 根据 id 查出价格
@ -751,12 +766,26 @@ class StoreProduct extends BaseController
}
$post_price = bcmul(bcmul((string)$store_product['price'],(string)$number),'100');
// 删除购物车
Db::table('cms_store_cart')->where($where)->update(['is_save'=>'1']);
$return['number'] = $number;
$store_product['number'] = $number;
$return['product'] = $store_product;
}
}else{
return to_assign(0, '请选择需要支付的商品');
}
Db::startTrans();//开启事务
if( count($return['product']) != count($return['product'], 1) ){
$html = "";
foreach ($return['product'] as $k =>$v){
$html .= "<div>商品名称:".$v['store_name']."</div><div>商品数量:".$v['number']."</div> 商品图片: <img src='".$v['image']."' style='width:50px;'>";
}
$return['html'] = $html;
}else{
$return['html'] = "<div>商品名称:".$return['product']['store_name']."</div><div>商品数量:".$return['product']['number']."</div> 商品图片:<img src='".$return['product']['image']."' style='width:50px;'>";
}
// 因为没有先创建订单, 所以这里先生成一个随机的订单号, 存在 pay_log 里, 用来标识订单, 支付成功后再把这个订单号存到 order 表里
$order_sn = date('ymd').substr((string)time(),-5).substr(microtime(),2,5);
$admin_id = get_login_admin('id');
@ -777,8 +806,8 @@ class StoreProduct extends BaseController
add_log('buy', $id, $param);
$app = $this->payment();
$total_fee = env('APP_DEBUG') ? 1 : $post_price;
// $total_fee = $post_price;
// $total_fee = env('APP_DEBUG') ? 1 : $post_price;
$total_fee = $post_price;
// 用 easywechat 封装的方法请求微信的统一下单接口
$result = $app->order->unify([
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
@ -809,9 +838,11 @@ class StoreProduct extends BaseController
// 订单编号, 用于在当前页面向微信服务器发起订单状态查询请求
$data['order_sn'] = $order_sn;
$data['html'] = Request::instance()->domain().'/'.$filename;
$data['data'] = $return;
Db::commit();
return to_assign(200,'操作成功',$data);
}
Db::rollback();
return to_assign(0,'操作失败');
}
@ -847,6 +878,13 @@ class StoreProduct extends BaseController
->withAttr('adminUser',function ($value,$data){
return Db::table('cms_admin')->where('id',$data['sh_admin_id'])->value('nickname');
})
->withAttr('find',function ($value,$data){
$find = Db::table('cms_store_msg')->where('admin_id',$this->uid)->find();
return $find;
})
->withAttr('create_time',function ($value,$data){
return date('Y-m-d H:i:s',$value);
})
->order('create_time desc')
->paginate($rows, false, ['query' => $param]);
@ -861,6 +899,27 @@ class StoreProduct extends BaseController
public function withdrawal(){
if (request()->isAjax()) {
$param = get_params();
$find = Db::table('cms_store_msg')->where('admin_id',$this->uid)->find();
if(empty($find)){
return to_assign(0, '请先设置收款方式');
}else{
if($param['skfs'] == 1){
if(empty($find['card_name']) || empty($find['bank']) || empty($find['card_code']) ){
return to_assign(0, '请先完善银行卡收款信息');
}
}
if($param['skfs'] == 2){
if(empty($find['wechat_name']) || empty($find['wechat_code']) || empty($find['wechat_img']) ){
return to_assign(0, '请先完善微信收款信息');
}
}
if($param['skfs'] == 3){
if(empty($find['alipay_name']) || empty($find['alipay_code']) || empty($find['alipay_img']) ){
return to_assign(0, '请先完善支付宝收款信息');
}
}
}
if($param['num'] < 100 ){
return to_assign(0, '最少提现100');
}else{
@ -872,7 +931,7 @@ class StoreProduct extends BaseController
$log_arr['num'] = $param['num'];
$log_arr['create_time'] = time();
$log_arr['status'] = 2;
$log_arr['mark'] = $param['mark'];
$log_arr['skfs'] = $param['skfs'];
$res = Db::table('cms_admin_money_log')->where('admin_id',$this->uid)->strict(false)->field(true)->insert($log_arr);
if($res){
return to_assign(200, '申请成功');
@ -967,9 +1026,9 @@ class StoreProduct extends BaseController
Db::startTrans();//开启事务
$app = $this->payment();
$order_sn = $paylog['out_trade_no'];
$total_fee = env('APP_DEBUG') ? 1 : $paylog['total_fee'];
// $total_fee = env('APP_DEBUG') ? 1 : $paylog['total_fee'];
// $total_fee = $post_price;
$total_fee = $paylog['total_fee'];
// 用 easywechat 封装的方法请求微信的统一下单接口
$result = $app->order->unify([
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
@ -1007,6 +1066,228 @@ class StoreProduct extends BaseController
return to_assign(0,'操作失败');
}
// 购物车保存
public function savecar(){
$param = get_params();
$id = $param['cart_id'];
if($id){
if(strpos($id,',')){ //多选购物车
$ids = explode(',',$id);
$post_price = '0';
$number = 0;
foreach ($ids as $k=>$v){
// 根据 id 查出价格
$where['cart_id'] = $v;
$where['uid'] = $this->uid;
$cart = Db::table('cms_store_cart')->where($where)->find();
if (empty($cart)) {
return to_assign(0,'查询的数据不存在');
}
// 删除购物车
Db::table('cms_store_cart')->where($where)->update(['is_save'=>'1']);
$wwww['product_id'] = $cart['product_id'];
$store_product = Db::table('cms_store_product')->where($wwww)->lock(true)->find();
if (empty($store_product)) {
return to_assign(0,'查询的数据不存在');
}
// 判断库存
if($store_product['stock'] < $number){
return to_assign(0,'超过库存数量');
}
$number += $cart['cart_num'];
$post_price = bcadd($post_price,bcmul(bcmul((string)$store_product['price'],(string)$number),'100'));
}
}else{
// 根据 id 查出价格
$where['cart_id'] = $id;
$where['uid'] = $this->uid;
$cart = Db::table('cms_store_cart')->where($where)->lock(true)->find();
if (empty($cart)) {
return to_assign(0,'查询的数据不存在');
}
$number = $cart['cart_num'];
$wwww['product_id'] = $cart['product_id'];
$store_product = Db::table('cms_store_product')->where($wwww)->lock(true)->find();
if (empty($store_product)) {
return to_assign(0,'查询的数据不存在');
}
// 判断库存
if($store_product['stock'] < $number){
return to_assign(0,'超过库存数量');
}
$post_price = bcmul(bcmul((string)$store_product['price'],(string)$number),'100');
// 删除购物车
Db::table('cms_store_cart')->where($where)->update(['is_save'=>'1']);
}
}else{
return to_assign(0, '请选择需要保存的商品');
}
Db::startTrans();//开启事务
// 因为没有先创建订单, 所以这里先生成一个随机的订单号, 存在 pay_log 里, 用来标识订单, 支付成功后再把这个订单号存到 order 表里
$order_sn = date('ymd').substr((string)time(),-5).substr(microtime(),2,5);
$admin_id = get_login_admin('id');
// 创建 Paylog 记录
$param =[
'appid' => 'wx0b3defb62f0f910b',
'mch_id' => '1635725673',
'out_trade_no' => $order_sn,
'product_id' => $id,
'number' => $number,
'admin_id' =>$admin_id,
'cart_id' =>$id,
'create_time'=>time(),
'total_fee' => $post_price
];
$res = Db::table('cms_store_product_paylog')->strict(false)->field(true)->insert($param);
if($res){
Db::commit();
return to_assign(200,'操作成功');
}else{
Db::rollback();
return to_assign(0,'操作失败');
}
}
// 资金流水
public function log(){
if (request()->isAjax()) {
$param = get_params();
$where[] = ['a.admin_id','=',$this->uid];
$where[] = ['a.status','=','1'];
$where[] = ['a.type','=','0'];
if (isset($param['keywords']) && !empty($param['keywords'])){
$where[]=['b.order_sn','=',$param['keywords']];
}
// if (isset($param['store_cate']) && !empty($param['store_cate'])){
// $where[]=['b.cate_id','=',$param['store_cate']];
// }
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
$list = Db::table('cms_admin_money_log')
->alias('a')
->join('cms_store_product_order b','a.order_id = b.id')
->withAttr('type',function ($value,$data){
return '订单支付';
})
->withAttr('name',function ($value,$data){
return Db::table('cms_admin')->where('id',$data['admin_id'])->value('nickname');
})
->withAttr('paid_at',function ($value,$data){
return date('Y-m-d H:i:s',(int)$value);
})
->where($where)
->order('a.id desc')
->paginate($rows, false, ['query' => $param]);
return table_assign(0, '', $list);
}
else{
return view();
}
}
// 转账记录
public function zzlog(){
return view('store_product/tixian');
}
// 收款方式
public function sktype(){
if (request()->isAjax()) {
$param = get_params();
$param['admin_id'] = $this->uid;
$where[] = ['admin_id','=',$this->uid];
$is_have = Db::table('cms_store_msg')->where($where)->find();
if($is_have){
$res = Db::table('cms_store_msg')->where($where)->strict(false)->field(true)->update($param);
}else{
$res = Db::table('cms_store_msg')->strict(false)->field(true)->insert($param);
}
if($res){
return to_assign(200,'操作成功');
}else{
return to_assign(0,'操作失败');
}
}
else{
$where[] = ['admin_id','=',$this->uid];
$list = Db::table('cms_store_msg')->where($where)->find();
if(empty($list)){
$list['card_name'] = '';
$list['bank'] = '';
$list['card_code'] = '';
$list['wechat_name'] = '';
$list['wechat_code'] = '';
$list['wechat_img'] = '';
$list['alipay_name'] = '';
$list['alipay_code'] = '';
$list['alipay_img'] = '';
}
View::assign('arr', $list);
return view();
}
}
// 账单管理
public function zdlist(){
if (request()->isAjax()) {
$param = get_params();
if(!isset($param['type'])){
$type = 1;
}else{
$type = $param['type'];
}
//当天
$day_start_time = strtotime(date('Y-m-d').'00:00:00');
$day_end_time = strtotime(date('Y-m-d').'23:59:59');
//本月
$yue_start_time = mktime(0,0,0,date('m'),1,date('Y')); //当月1号
$yue_end_time = mktime(23,59,59,date('m'),date('t'),date('Y')); //当月最后一天
if($type == 2){
$list[0]['id'] = '1';
$list[0]['time'] = date('Y-m');
$where[] = ['type','=','0'];
$where[] = ['status','=','1'];
$where[] = $www[] = ['create_time','between',[$yue_start_time,$yue_end_time]];
$shouru = Db::table('cms_admin_money_log')->where($where)->sum('num');
$www[] = ['type','=','1'];
$www[] = ['status','=','3'];
$zhichu = Db::table('cms_admin_money_log')->where($www)->sum('num');
$list[0]['shouru'] = $shouru;
$list[0]['zhichu'] = $zhichu;
$list[0]['money'] = $shouru - $zhichu;
}else{
$list[0]['id'] = '1';
$list[0]['time'] = date('Y-m-d');
$where[] = ['type','=','0'];
$where[] = ['status','=','1'];
$where[] = $www[] = ['create_time','between',[$day_start_time,$day_end_time]];
$shouru = Db::table('cms_admin_money_log')->where($where)->sum('num');
$www[] = ['type','=','1'];
$www[] = ['status','=','3'];
$zhichu = Db::table('cms_admin_money_log')->where($www)->sum('num');
$list[0]['shouru'] = $shouru;
$list[0]['zhichu'] = $zhichu;
$list[0]['money'] = $shouru - $zhichu;
}
return to_assign(0, '', $list);
}
else{
return view();
}
}
}

View File

@ -51,7 +51,8 @@
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-sm" lay-event="paycar" data-title="支付">支付</span>
<span class="layui-btn layui-btn-sm preservation" lay-event="paycar" data-title="支付">支付</span>
<span class="layui-btn layui-btn-sm preservations" lay-event="saveorder" data-title="保存">保存</span>
</div>
</script>
@ -129,14 +130,14 @@
})
newJson.join(",");
if (newJson.length == 0){
layer.msg("请选择需要操作数据")
layer.msg("请选择需要操作数据");
}else {
// 单击之后提交按钮不可选,防止重复提交
var DISABLED = 'layui-btn-disabled';
// 增加样式
$('.preservation').addClass(DISABLED);
// 增加属性
$('.preservation').attr('disabled', 'disabled');
$('.preservation').attr('lay-event', 'paycar_disabled');
$.ajax({
url : "/admin/store_product/paycar?cart_id="+newJson, //请求的url地址
@ -157,9 +158,9 @@
shade: 0.3,
maxmin: false, //开启最大化最小化按钮
//宽高
area: ['250px','250px'],
area: ['1000px','800px'],
//内容
content: "<img src='"+url+"' alt='' style='margin-left: 40px;'>",
content: "<div>"+data.data.data.html+"</div> 扫码支付:<img src='"+url+"' alt='' style='margin-left: 40px;'>",
});
/** 设置定时器, 即一弹出二维码就开始不断请求查看支付状态, 直到收到支付成功的返回, 再终止定时器 **/
@ -192,19 +193,75 @@
tool.ajax(options, callback);
}, 3000);
// 恢复按钮
var DISABLED = 'layui-btn-disabled';
$('.preservation').removeClass(DISABLED);
$('.preservation').removeAttr('disabled');
$('.preservation').attr('lay-event', 'paycar');
},
complete : function() {
//请求完成的处理
},
error : function() {
// 恢复按钮
var DISABLED = 'layui-btn-disabled';
$('.preservation').removeClass(DISABLED);
$('.preservation').removeAttr('disabled');
$('.preservation').attr('lay-event', 'paycar');
//请求出错处理
layer.alert("系统异常");
}
});
// 恢复按钮
}
}
else if (obj.event === 'saveorder') {
//获取选中数据
var checkStatus = table.checkStatus('testReload')
,data = checkStatus.data;
var newJson = []
$.each(data, function (index, item) {
newJson.push(item.cart_id);
})
newJson.join(",");
if (newJson.length == 0){
layer.msg("请选择需要操作数据")
}else {
// 单击之后提交按钮不可选,防止重复提交
var DISABLED = 'layui-btn-disabled';
$('.preservation').removeClass(DISABLED);
$('.preservation').removeAttr('disabled');
// 增加样式
$('.preservations').addClass(DISABLED);
// 增加属性
$('.preservations').attr('lay-event', 'saveorder_disabled');
$.ajax({
url : "/admin/store_product/savecar?cart_id="+newJson, //请求的url地址
dataType : "json", //返回格式为json
async : true,//请求是否异步默认为异步这也是ajax重要特性
type : "POST", //请求方式
success : function(res) {
if (res.code == 200) {
layer.msg('保存成功',{time:2000,icon:6});
// 关闭所有层
setTimeout(function () {
layer.closeAll();
}, 2000);
// tool.sideClose(2000);
location.reload();
}
},
complete : function() {
//请求完成的处理
},
error : function() {
// 恢复按钮
var DISABLED = 'layui-btn-disabled';
$('.preservations').removeClass(DISABLED);
$('.preservations').removeAttr('disabled');
$('.preservation').attr('lay-event', 'saveorder');
//请求出错处理
layer.alert("系统异常");
}
});
}
}
});

View File

@ -0,0 +1,238 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
.layui-input-inline{
width:35% !important;
}
.layui-input-inline .layui-form-item{
display:flex;
}
.layui-input-inline .layui-form-item .layui-form-label{
width:30%;
}
.layui-input-block{
margin-left:unset !important;
width:75%;
}
#seleform{
border-color: #eee;
background-color: #fff;
color:#a39f9f;
width:100%;
}
</style>
<div class="p-3">
<form id="filterform" class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入订单号" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
</form>
<table class="layui-hide" id="store_product" lay-filter="store_product"></table>
</div>
<script type="text/html" id="barDemo">
<div class="layui-btn-group"></div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#store_product',
title: '商品表列表',
toolbar: '#toolbarDemo',
url: '/admin/store_product/log',
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'left',
field: 'id',
title: '编号',
align: 'center',
width: 80
},{
field: 'order_sn',
title: '订单号',
align: 'center',
width: 180
},{
field: 'paid_at',
title: '交易时间',
align: 'center',
width: 150,
},{
field: 'name',
title: '对方信息',
align: 'center',
width: 150
},{
field: 'type',
title: '交易类型',
align: 'center',
width: 100
},{
field: 'total_fee',
title: '收支金额(元)',
align: 'center',
width: 150
}, {
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 136,
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(store_product)', function(obj){
if (obj.event === 'add') {
tool.side("/admin/store_product/add");
return false;
}
if (obj.event === 'adds') {
tool.side("/admin/store_product/adds");
return false;
}
});
// 商户商品分类搜索
layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){
var dropdown = layui.dropdown
,util = layui.util
,layer = layui.layer
,rate = layui.rate
// ,table = layui.table
,$ = layui.jquery;
var $ = layui.$, active = {
reload: function(){
let dataRload = getformdata();
//执行重载
table.reload('store_product', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
...dataRload
}
});
},
};
//基础效果
rate.render({
elem: '#is_good'
})
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
...data.field
},
page: {
curr: 1
}
});
return false;
});
//监听select提交
form.on('select(seleform)', function(data) {
active['reload'] ? active['reload'].call(this) : '';
return false;
});
//监听removeselect点击
$('#removeselect').on('click', function(){
$('#seleform').text('请选择');
$('#seleform').css({color:'#a39f9f'});
$('#store_cate').val('');
active['reload'] ? active['reload'].call(this) : '';
return false;
});
// tab 状态列表切换
$('.site-demo-active').on('click', function(){
var othis = $(this), type = othis.data('type');
$('#protype').val(this.getAttribute('type'));
active[type] ? active[type].call(this, othis) : '';
});
});
//监听表格行工具事件
table.on('tool(store_product)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('/admin/store_product/read?product_id='+obj.data.product_id);
}
else if (obj.event === 'edit') {
tool.side('/admin/store_product/edit?product_id='+obj.data.product_id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/store_product/del", { product_id: data.product_id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
return false;
});
// 获取表单所有参数
function getformdata() {
var form = $('#filterform').serializeArray();
var data = new Array();
for(let i=0;i<form.length; i++){
data[form[i].name] = form[i].value;
}
return data;
}
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -104,6 +104,11 @@
title: '订单金额',
align: 'center',
width: 100
},{
field: 'name',
title: '商户',
align: 'center',
width: 200,
},{
field: 'product',
title: '商品简介',

View File

@ -0,0 +1,209 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">收款方式</h3>
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
<li class="layui-this">银行卡</li>
<li>微信</li>
<li>支付宝</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<form class="layui-form p-4">
<div class="layui-form-item">
<label class="layui-form-label">姓名</label>
<div class="layui-input-block">
<input type="text" value="{$arr.card_name}" autocomplete="off" class="layui-input" name="card_name">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">开户银行</label>
<div class="layui-input-block">
<input type="text" name="bank" value="{$arr.bank}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">银行卡号</label>
<div class="layui-input-block">
<input type="text" name="card_code" value="{$arr.card_code}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform1">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
</div>
<div class="layui-tab-item">
<form class="layui-form p-4">
<div class="layui-form-item">
<label class="layui-form-label">姓名</label>
<div class="layui-input-block">
<input type="text" name="wechat_name" value="{$arr['wechat_name']}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">微信号</label>
<div class="layui-input-block">
<input type="text" name="wechat_code" value="{$arr['wechat_code']}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-upload layui-input-block">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">
微信收款二维码
</button>
<div class="layui-upload-list" id="upload_box_thumb"
style=" overflow: hidden;">
<img src="{$arr.wechat_img}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="wechat_img" value="">
</div>
</div>
</div>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform2">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
</div>
<div class="layui-tab-item">
<form class="layui-form p-4">
<div class="layui-form-item">
<label class="layui-form-label">姓名</label>
<div class="layui-input-block">
<input type="text" name="alipay_name" value="{$arr['alipay_name']}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">支付宝账号</label>
<div class="layui-input-block">
<input type="text" name="alipay_code" value="{$arr['alipay_code']}" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-upload layui-input-block">
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb2">
支付宝收款二维码
</button>
<div class="layui-upload-list" id="upload_box_thumb2"
style=" overflow: hidden;">
<img src="{$arr.alipay_img}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="alipay_img" value="">
</div>
</div>
</div>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform3">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
</div>
</div>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var moduleInit = ['tool'];
function ceshi(e){
$(e).parent().remove();
}
function gouguInit () {
var form = layui.form, tool = layui.tool;
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//上传缩略图
var upload_thumb2 = layui.upload.render({
elem: '#upload_btn_thumb2',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb2 input').attr('value', res.data.filepath);
$('#upload_box_thumb2 img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform1)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 200) {
tool.sideClose(1000);
}
}
tool.post("/admin/store_product/sktype", data.field, callback);
return false;
});
form.on('submit(webform2)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 200) {
tool.sideClose(1000);
}
}
tool.post("/admin/store_product/sktype", data.field, callback);
return false;
});
form.on('submit(webform3)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 200) {
tool.sideClose(1000);
}
}
tool.post("/admin/store_product/sktype", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -89,23 +89,43 @@
field: 'nickname',
title: '用户',
align: 'center',
width: 200,
width: 120,
},{
field: 'num',
title: '提现金额',
align: 'center',
width: 100
},{
field: 'mark',
title: '提现卡号',
field: 'skfs',
title: '收款方式',
align: 'center',
width:150,
width:300,
templet: function (d)
{
if(d.skfs == 1)
{
return '银行卡姓名:'+d.find.card_name+', '+'开户银行:'+d.find.bank+', '+'银行卡号:'+d.find.card_code;
}
if(d.skfs == 2)
{
return '微信姓名:'+d.find.wechat_name+', '+'微信号:'+d.find.wechat_code+', '+'微信收款二维码:'+'<img src="'+d.find.wechat_img+'" style="width:40px; height:40px;">';
}
if(d.skfs == 3)
{
return '支付宝姓名:'+d.find.alipay_name+', '+'支付宝账号:'+d.find.alipay_code+', '+'支付宝收款二维码:'+'<img src="'+d.find.alipay_img+'" style="width:40px; height:40px;">';
}
return '无';
}
},{
field: 'create_time',
title: '提现时间',
align: 'center',
width: 100
width: 150
},{
field: 'status',
title: '状态',

View File

@ -25,8 +25,14 @@
<tr>
<td class="layui-td-gray">银行卡号<font>*</font></td>
<td colspan="7"><input type="text" name="mark" lay-verify="required" lay-reqText="请输入银行卡号"
autocomplete="off" placeholder="请输入银行卡号" class="layui-input"></td>
<td colspan="7">
<select name="skfs" lay-verify="required" lay-search="">
<option value="">请选择收款方式</option>
<option value="1">银行卡</option>
<option value="2">微信</option>
<option value="3">支出宝</option>
</select>
</td>
</tr>

View File

@ -0,0 +1,250 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
.layui-input-inline{
width:35% !important;
}
.layui-input-inline .layui-form-item{
display:flex;
}
.layui-input-inline .layui-form-item .layui-form-label{
width:30%;
}
.layui-input-block{
margin-left:unset !important;
width:75%;
}
#seleform{
border-color: #eee;
background-color: #fff;
color:#a39f9f;
width:100%;
}
</style>
<div class="p-3">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this site-demo-active" type="1" data-type="reload">日账单</li>
<li class="site-demo-active" type="2" data-type="reload">月账单</li>
</ul>
</div>
<form id="filterform" class="layui-form gg-form-bar border-t border-x">
<input id="protype" type="hidden" name="type" value="1">
<div class="layui-form-item">
<!-- <div class="layui-input-inline">-->
<!-- <div class="layui-form-item">-->
<!-- <label class="layui-form-label">商品分类</label>-->
<!-- <div class="layui-input-block">-->
<!-- <input id="store_cate" type="hidden" readonly="readonly" name="store_cate">-->
<!-- <button id="seleform" lay-filter="seleform" class="layui-btn">请选择</button>-->
<!-- <div id="removeselect"><i class="bi-x-lg" style="position: absolute;right:2px;top:10px;z-index: 9;cursor:pointer;"></i></div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
<!-- <div class="layui-input-inline" style="width:300px;">-->
<!-- <input type="text" name="keywords" placeholder="请输入订单号" class="layui-input" autocomplete="off" />-->
<!-- </div>-->
<!-- <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>-->
</form>
<table class="layui-hide" id="store_product" lay-filter="store_product"></table>
</div>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs preservation {{# if(d.status != 0){ }}layui-hide{{# } }}" lay-event="topay">去支付</a>
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#store_product',
title: '列表',
toolbar: '#toolbarDemo',
url: '/admin/store_product/zdlist',
page: false,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'left',
field: 'id',
title: '编号',
align: 'center',
width: 80
},{
field: 'time',
title: '日期',
align: 'center',
width: 200,
},{
field: 'shouru',
title: '账期内收入',
align: 'center',
width: 100
},{
field: 'zhichu',
title: '账期内支出',
align: 'center',
width: 100
},{
field: 'money',
title: '商户应入账金额',
align: 'center',
width: 200,
},
]
]
});
//监听表头工具栏事件
table.on('toolbar(store_product)', function(obj){
if (obj.event === 'add') {
tool.side("/admin/store_product/add");
return false;
}
});
//监听表格行工具事件
table.on('tool(store_product)', function(obj) {
var data = obj.data;
if (obj.event === 'topay') {
}
else if (obj.event === 'edit') {
tool.side('/admin/store_product/edit?product_id='+obj.data.product_id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/store_product/del", { product_id: data.product_id }, callback);
layer.close(index);
});
}
return false;
});
// 商户商品分类搜索
layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){
var dropdown = layui.dropdown
,util = layui.util
,layer = layui.layer
,rate = layui.rate
// ,table = layui.table
,$ = layui.jquery;
var $ = layui.$, active = {
reload: function(){
let dataRload = getformdata();
//执行重载
table.reload('store_product', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
...dataRload
}
});
},
};
//基础效果
rate.render({
elem: '#is_good'
})
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
...data.field
},
page: {
curr: 1
}
});
return false;
});
//监听select提交
form.on('select(seleform)', function(data) {
active['reload'] ? active['reload'].call(this) : '';
return false;
});
//监听removeselect点击
$('#removeselect').on('click', function(){
$('#seleform').text('请选择');
$('#seleform').css({color:'#a39f9f'});
$('#store_cate').val('');
active['reload'] ? active['reload'].call(this) : '';
return false;
});
// tab 状态列表切换
$('.site-demo-active').on('click', function(){
var othis = $(this), type = othis.data('type');
$('#protype').val(this.getAttribute('type'));
active[type] ? active[type].call(this, othis) : '';
});
});
// //监听搜索提交
// form.on('submit(searchform)', function(data) {
// layui.pageTable.reload({
// where: {
// keywords: data.field.keywords
// },
// page: {
// curr: 1
// }
// });
// return false;
// });
// 获取表单所有参数
function getformdata() {
var form = $('#filterform').serializeArray();
var data = new Array();
for(let i=0;i<form.length; i++){
data[form[i].name] = form[i].value;
}
return data;
}
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -107,7 +107,7 @@ class PayNotify extends BaseController
'number' => $payLog['number'],
'cart_id' => $payLog['cart_id'],
];
Db::table('cms_store_product_order')->strict(false)->field(true)->insert($order_arr);
$order_id = Db::table('cms_store_product_order')->strict(false)->field(true)->insertGetId($order_arr);
// 更新 PayLog, 这里的字段都是根据微信支付结果通知的字段设置的(https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_7&index=8)
$pay_log = [
@ -169,6 +169,7 @@ class PayNotify extends BaseController
$log_arr['num'] = $total_fee;
$log_arr['create_time'] = $time;
$log_arr['status'] = 1;
$log_arr['order_id'] = $order_id;
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
}
}else{
@ -202,6 +203,7 @@ class PayNotify extends BaseController
$log_arr['num'] = $total_fee;
$log_arr['create_time'] = $time;
$log_arr['status'] = 1;
$log_arr['order_id'] = $order_id;
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
}
}
@ -232,6 +234,7 @@ class PayNotify extends BaseController
$log_arr['num'] = $total_fee;
$log_arr['create_time'] = time();
$log_arr['status'] = 1;
$log_arr['order_id'] = $order_id;
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
}
}