提现
This commit is contained in:
parent
d5405d65ee
commit
c0ff1742fd
@ -5,7 +5,6 @@
|
|||||||
* @link https://www.gougucms.com
|
* @link https://www.gougucms.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare (strict_types = 1);
|
|
||||||
|
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
@ -51,6 +50,7 @@ class StoreProduct extends BaseController
|
|||||||
$list[$k]['brand_id'] = Db::connect('shop')->table('eb_store_brand')->where($www)->value('brand_name');
|
$list[$k]['brand_id'] = Db::connect('shop')->table('eb_store_brand')->where($www)->value('brand_name');
|
||||||
$www2['store_category_id'] = $v['cate_id'];
|
$www2['store_category_id'] = $v['cate_id'];
|
||||||
$list[$k]['cate_id'] = Db::connect('shop')->table('eb_store_category')->where($www2)->value('cate_name');
|
$list[$k]['cate_id'] = Db::connect('shop')->table('eb_store_category')->where($www2)->value('cate_name');
|
||||||
|
$list[$k]['shangjia'] = Db::table('cms_admin')->where('id',$this->uid)->value('nickname');
|
||||||
}
|
}
|
||||||
return table_assign(0, '', $list);
|
return table_assign(0, '', $list);
|
||||||
}
|
}
|
||||||
@ -343,6 +343,7 @@ class StoreProduct extends BaseController
|
|||||||
$list[$k]['brand_id'] = Db::connect('shop')->table('eb_store_brand')->where($www)->value('brand_name');
|
$list[$k]['brand_id'] = Db::connect('shop')->table('eb_store_brand')->where($www)->value('brand_name');
|
||||||
$www2['store_category_id'] = $v['cate_id'];
|
$www2['store_category_id'] = $v['cate_id'];
|
||||||
$list[$k]['cate_id'] = Db::connect('shop')->table('eb_store_category')->where($www2)->value('cate_name');
|
$list[$k]['cate_id'] = Db::connect('shop')->table('eb_store_category')->where($www2)->value('cate_name');
|
||||||
|
$list[$k]['shangjia'] = Db::table('cms_admin')->where('id',$this->uid)->value('nickname');
|
||||||
}
|
}
|
||||||
return table_assign(0, '', $list);
|
return table_assign(0, '', $list);
|
||||||
}
|
}
|
||||||
@ -383,6 +384,8 @@ class StoreProduct extends BaseController
|
|||||||
'key' => '95d195Dcf6ec66156dfeeb4E7435faef',//支付秘钥
|
'key' => '95d195Dcf6ec66156dfeeb4E7435faef',//支付秘钥
|
||||||
'secret' => 'c02aa7ad9e4a5c423862e068b6cb4ad4',
|
'secret' => 'c02aa7ad9e4a5c423862e068b6cb4ad4',
|
||||||
'notify_url' => Request::instance()->domain().'/api/PayNotify/notify',//异步回调通知地址
|
'notify_url' => Request::instance()->domain().'/api/PayNotify/notify',//异步回调通知地址
|
||||||
|
// 'notify_url' => 'http://t7kqa2.natappfree.cc/api/PayNotify/notify',//异步回调通知地址
|
||||||
|
|
||||||
];
|
];
|
||||||
// 这个就是 easywechat 封装的了, 一行代码搞定, 照着写就行了
|
// 这个就是 easywechat 封装的了, 一行代码搞定, 照着写就行了
|
||||||
$app = Factory::payment($config);
|
$app = Factory::payment($config);
|
||||||
@ -419,13 +422,14 @@ class StoreProduct extends BaseController
|
|||||||
'product_id' => $id,
|
'product_id' => $id,
|
||||||
'number' => $number,
|
'number' => $number,
|
||||||
'admin_id' =>$admin_id,
|
'admin_id' =>$admin_id,
|
||||||
|
'create_time'=>time(),
|
||||||
];
|
];
|
||||||
Db::table('cms_store_product_paylog')->strict(false)->field(true)->insert($param);
|
Db::table('cms_store_product_paylog')->strict(false)->field(true)->insert($param);
|
||||||
add_log('buy', $id, $param);
|
add_log('buy', $id, $param);
|
||||||
$app = $this->payment();
|
$app = $this->payment();
|
||||||
|
|
||||||
// $total_fee = env('APP_DEBUG') ? 1 : $post_price;
|
$total_fee = env('APP_DEBUG') ? 1 : $post_price;
|
||||||
$total_fee = $post_price;
|
// $total_fee = $post_price;
|
||||||
// 用 easywechat 封装的方法请求微信的统一下单接口
|
// 用 easywechat 封装的方法请求微信的统一下单接口
|
||||||
$result = $app->order->unify([
|
$result = $app->order->unify([
|
||||||
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
|
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
|
||||||
@ -482,6 +486,13 @@ class StoreProduct extends BaseController
|
|||||||
public function order(){
|
public function order(){
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
$param = get_params();
|
$param = get_params();
|
||||||
|
if(!isset($param['type'])){
|
||||||
|
$type = 1;
|
||||||
|
}else{
|
||||||
|
$type = $param['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($type == 2){
|
||||||
$where[] = ['a.admin_id','=',$this->uid];
|
$where[] = ['a.admin_id','=',$this->uid];
|
||||||
if (isset($param['keywords']) && !empty($param['keywords'])){
|
if (isset($param['keywords']) && !empty($param['keywords'])){
|
||||||
$where[]=['b.store_name','like','%'.$param['keywords'].'%'];
|
$where[]=['b.store_name','like','%'.$param['keywords'].'%'];
|
||||||
@ -497,9 +508,176 @@ class StoreProduct extends BaseController
|
|||||||
->withAttr('paid_at',function ($value,$data){
|
->withAttr('paid_at',function ($value,$data){
|
||||||
return date('Y-m-d H:i:s',(int)$value);
|
return date('Y-m-d H:i:s',(int)$value);
|
||||||
})
|
})
|
||||||
|
->withAttr('product',function ($value,$data){
|
||||||
|
if($data['cart_id']){
|
||||||
|
$product_id = Db::table('cms_store_cart')->where('cart_id','in',$data['cart_id'])->column('product_id');
|
||||||
|
$product = Db::table('cms_store_product')->where('product_id','in',$product_id)->field('image,store_name')->select()->toArray();
|
||||||
|
return $product;
|
||||||
|
}else{
|
||||||
|
$product[0]['store_name'] = $data['store_name'];
|
||||||
|
$product[0]['image'] = $data['image'];
|
||||||
|
return $product;
|
||||||
|
}
|
||||||
|
})
|
||||||
->where($where)
|
->where($where)
|
||||||
->order('a.id desc,a.paid_at desc')
|
->order('a.id desc,a.paid_at desc')
|
||||||
->paginate($rows, false, ['query' => $param]);;
|
->paginate($rows, false, ['query' => $param]);
|
||||||
|
|
||||||
|
return table_assign(0, '', $list);
|
||||||
|
}else{
|
||||||
|
$where[] = ['admin_id','=',$this->uid];
|
||||||
|
if (isset($param['keywords']) && !empty($param['keywords'])){
|
||||||
|
$where[]=['store_name','like','%'.$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_store_product_paylog')
|
||||||
|
->withAttr('product',function ($value,$data){
|
||||||
|
if($data['cart_id']){
|
||||||
|
$product_id = Db::table('cms_store_cart')->where('cart_id','in',$data['cart_id'])->column('product_id');
|
||||||
|
$product = Db::table('cms_store_product')->where('product_id','in',$product_id)->field('image,store_name')->select()->toArray();
|
||||||
|
return $product;
|
||||||
|
}else{
|
||||||
|
$arr = Db::table('cms_store_product')->where('product_id','=',$data['product_id'])->field('image,store_name')->find();
|
||||||
|
$product[0]['store_name'] = $arr['store_name'];
|
||||||
|
$product[0]['image'] = $arr['image'];
|
||||||
|
return $product;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->withAttr('paid_at',function ($value,$data){
|
||||||
|
return '';
|
||||||
|
})
|
||||||
|
->where($where)
|
||||||
|
->order('id desc')
|
||||||
|
->paginate($rows, false, ['query' => $param]);
|
||||||
|
|
||||||
|
return table_assign(0, '', $list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//一条龙,丧葬商品,宴席,婚礼策划,婚纱礼服,婚娶服务,婚车租赁,婚品服务,宴席,水果类,蔬菜类,粮食类,生鲜类,蛋奶类,肉禽类,种子,化肥,农药,农机,农具,禽苗,家政保洁,家电维修,保姆月嫂,洗涤护理,法律咨询,求职招聘,开锁换钥,洗漱用品,化妆品,纸巾,洗衣粉,日常调料,酒水,饮料,零食,日杂百货,休闲食品,生活用品
|
||||||
|
// 加入购物车
|
||||||
|
public function joincar(){
|
||||||
|
$data = get_params();
|
||||||
|
$result = $this->cartCheck($data,$this->uid);
|
||||||
|
if ($cart = $result['cart']) {
|
||||||
|
//更新购物车
|
||||||
|
$cart_id = $cart['cart_id'];
|
||||||
|
$cart_num = ['cart_num' => ($cart['cart_num'] + $data['cart_num'])];
|
||||||
|
$where = [
|
||||||
|
'cart_id' => $cart_id,
|
||||||
|
];
|
||||||
|
$storeCart = Db::table('cms_store_cart')->where($where)->update($cart_num);
|
||||||
|
} else {
|
||||||
|
//添加购物车
|
||||||
|
$data['uid'] = $this->uid;
|
||||||
|
$data['mer_id'] = $result['product']['admin_id'];
|
||||||
|
$cart = $storeCart = Db::table('cms_store_cart')->insert($data);
|
||||||
|
}
|
||||||
|
return to_assign(200, '操作成功',$storeCart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 普通商品加入购物车检测
|
||||||
|
* @param int $prodcutId
|
||||||
|
* @param string $unique
|
||||||
|
* @param int $cartNum
|
||||||
|
* @author Qinii
|
||||||
|
* @day 2020-10-20
|
||||||
|
*/
|
||||||
|
public function cartCheck(array $data, $userInfo)
|
||||||
|
{
|
||||||
|
$cart = null;
|
||||||
|
$where = [
|
||||||
|
'status' => 1,
|
||||||
|
'is_used' => 1,
|
||||||
|
'product_type' => 0,
|
||||||
|
'is_gift_bag' => 0,
|
||||||
|
];
|
||||||
|
$where['product_id'] = $data['product_id'];
|
||||||
|
unset($where['is_gift_bag']);
|
||||||
|
$product = Db::table('cms_store_product')->where($where)->find();
|
||||||
|
|
||||||
|
if (!$product) throw new ValidateException('商品已下架');
|
||||||
|
// if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
|
||||||
|
// $value_make = app()->make(ProductAttrValueRepository::class);
|
||||||
|
// $sku = $value_make->getOptionByUnique($data['product_attr_unique']);
|
||||||
|
// if (!$sku) throw new ValidateException('SKU不存在');
|
||||||
|
|
||||||
|
|
||||||
|
//立即购买 限购
|
||||||
|
if ($data['is_new']) {
|
||||||
|
$cart_num = $data['cart_num'];
|
||||||
|
} else {
|
||||||
|
//加入购物车
|
||||||
|
//购物车现有
|
||||||
|
$_num = $this->productOnceCountCart($where['product_id'],$data['product_attr_unique'], $userInfo);
|
||||||
|
$cart_num = $_num + $data['cart_num'];
|
||||||
|
}
|
||||||
|
if ($product['stock'] < $cart_num ){
|
||||||
|
return to_assign(0, '库存不足');
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加购物车
|
||||||
|
// if (!$data['is_new']) {
|
||||||
|
// $cart = app()->make(StoreCartRepository::class)->getCartByProductSku($data['product_attr_unique'], $userInfo);
|
||||||
|
// }
|
||||||
|
return compact('product', 'cart');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 购物车单商品数量
|
||||||
|
* @param $productId
|
||||||
|
* @param $uid
|
||||||
|
* @param $num
|
||||||
|
* @author Qinii
|
||||||
|
* @day 5/26/21
|
||||||
|
*/
|
||||||
|
public function productOnceCountCart($productId,$product_attr_unique,$uid)
|
||||||
|
{
|
||||||
|
$where = [
|
||||||
|
'is_pay' => 0,
|
||||||
|
'is_del' => 0,
|
||||||
|
'is_new' => 0,
|
||||||
|
'is_fail' => 0,
|
||||||
|
'is_dg' => 0,
|
||||||
|
'product_type' => 0,
|
||||||
|
'product_id' => $productId,
|
||||||
|
'uid' => $uid,
|
||||||
|
];
|
||||||
|
$cart_num = Db::table('cms_store_cart')->where($where)->sum('cart_num');
|
||||||
|
return $cart_num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 购物车列表
|
||||||
|
public function carlist(){
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$param = get_params();
|
||||||
|
$where[] = ['a.uid','=',$this->uid];
|
||||||
|
$where[] = ['a.is_pay','=',0];
|
||||||
|
$where[] = ['a.is_del','=',0];
|
||||||
|
$where[] = ['a.is_fail','=',0];
|
||||||
|
if (isset($param['keywords']) && !empty($param['keywords'])){
|
||||||
|
$where[]=['b.nickname','like','%'.$param['keywords'].'%'];
|
||||||
|
}
|
||||||
|
if (isset($param['product_id']) && !empty($param['product_id'])){
|
||||||
|
$where[]=['c.product_id','=',$param['product_id']];
|
||||||
|
}
|
||||||
|
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||||
|
$list = Db::table('cms_store_cart')
|
||||||
|
->alias('a')
|
||||||
|
->join('cms_admin b','a.uid = b.id')
|
||||||
|
->join('cms_store_product c','a.product_id = c.product_id')
|
||||||
|
->field('a.*,c.image,b.nickname,c.store_name')
|
||||||
|
->where($where)
|
||||||
|
->order('a.cart_id desc')
|
||||||
|
->paginate($rows, false, ['query' => $param]);
|
||||||
return table_assign(0, '', $list);
|
return table_assign(0, '', $list);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -507,5 +685,259 @@ class StoreProduct extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 购物车支付
|
||||||
|
public function paycar(){
|
||||||
|
$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)->lock(true)->find();
|
||||||
|
if (empty($cart)) {
|
||||||
|
return to_assign(0,'查询的数据不存在');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
}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()
|
||||||
|
];
|
||||||
|
|
||||||
|
Db::table('cms_store_product_paylog')->strict(false)->field(true)->insert($param);
|
||||||
|
add_log('buy', $id, $param);
|
||||||
|
$app = $this->payment();
|
||||||
|
|
||||||
|
$total_fee = env('APP_DEBUG') ? 1 : $post_price;
|
||||||
|
// $total_fee = $post_price;
|
||||||
|
// 用 easywechat 封装的方法请求微信的统一下单接口
|
||||||
|
$result = $app->order->unify([
|
||||||
|
'trade_type' => 'NATIVE', // 原生支付即扫码支付,商户根据微信支付协议格式生成的二维码,用户通过微信“扫一扫”扫描二维码后即进入付款确认界面,输入密码即完成支付。
|
||||||
|
'body' => '购物车商品-订单支付', // 这个就是会展示在用户手机上巨款界面的一句话, 随便写的
|
||||||
|
'out_trade_no' => $order_sn,
|
||||||
|
'total_fee' => $total_fee,
|
||||||
|
'spbill_create_ip' => request()->ip(), // 可选,如不传该参数,SDK 将会自动获取相应 IP 地址
|
||||||
|
]);
|
||||||
|
if ($result['result_code'] == 'SUCCESS') {
|
||||||
|
// 如果请求成功, 微信会返回一个 'code_url' 用于生成二维码
|
||||||
|
$code_url = $result['code_url'];
|
||||||
|
// 生成二维码
|
||||||
|
// 引用二维码生成方法
|
||||||
|
require '../vendor/phpqrcode/phpqrcode.php';
|
||||||
|
|
||||||
|
$errorCorrectionLevel = 'L'; //容错级别
|
||||||
|
$matrixPointSize = 5; //生成图片大小
|
||||||
|
//生成二维码图片
|
||||||
|
// 判断是否有这个文件夹 没有的话就创建一个
|
||||||
|
if(!is_dir("static/qrcode")){
|
||||||
|
// 创建文件加
|
||||||
|
mkdir("static/qrcode");
|
||||||
|
}
|
||||||
|
//设置二维码文件名
|
||||||
|
$filename = 'static/qrcode/'.time().rand(10000,9999999).'.png';
|
||||||
|
//生成二维码
|
||||||
|
\QRcode::png($code_url,$filename , $errorCorrectionLevel, $matrixPointSize, 2);
|
||||||
|
// 订单编号, 用于在当前页面向微信服务器发起订单状态查询请求
|
||||||
|
$data['order_sn'] = $order_sn;
|
||||||
|
$data['html'] = Request::instance()->domain().'/'.$filename;
|
||||||
|
Db::commit();
|
||||||
|
return to_assign(200,'操作成功',$data);
|
||||||
|
}
|
||||||
|
return to_assign(0,'操作失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function delcar(){
|
||||||
|
$param = get_params();
|
||||||
|
$where['cart_id'] = $param['cart_id'];
|
||||||
|
$res = Db::table('cms_store_cart')->where($where)->delete();
|
||||||
|
if($res){
|
||||||
|
return to_assign(200, '删除成功');
|
||||||
|
}else{
|
||||||
|
return to_assign(0, '删除失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提现记录列表
|
||||||
|
public function tixian(){
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$param = get_params();
|
||||||
|
$where[] = ['admin_id','=',$this->uid];
|
||||||
|
$where[] = ['type','=',1];
|
||||||
|
if (isset($param['status']) && !empty($param['status'])){
|
||||||
|
$where[]=['status','=',$param['status']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||||
|
$list = Db::table('cms_admin_money_log')
|
||||||
|
->where($where)
|
||||||
|
->withAttr('nickname',function ($value,$data){
|
||||||
|
return Db::table('cms_admin')->where('id',$this->uid)->value('nickname');
|
||||||
|
})
|
||||||
|
->withAttr('adminUser',function ($value,$data){
|
||||||
|
return Db::table('cms_admin')->where('id',$data['sh_admin_id'])->value('nickname');
|
||||||
|
})
|
||||||
|
->order('create_time desc')
|
||||||
|
->paginate($rows, false, ['query' => $param]);
|
||||||
|
|
||||||
|
return table_assign(0, '', $list);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 申请提现
|
||||||
|
public function withdrawal(){
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$param = get_params();
|
||||||
|
if($param['num'] < 100 ){
|
||||||
|
return to_assign(0, '最少提现100');
|
||||||
|
}else{
|
||||||
|
$arr = Db::table('cms_admin_money')->where('admin_id',$this->uid)->find();
|
||||||
|
if($arr && $arr['money'] >= $param['num']){
|
||||||
|
//写入后台余额记录表
|
||||||
|
$log_arr['type'] = 1;
|
||||||
|
$log_arr['admin_id'] = $this->uid;
|
||||||
|
$log_arr['num'] = $param['num'];
|
||||||
|
$log_arr['create_time'] = time();
|
||||||
|
$log_arr['status'] = 2;
|
||||||
|
$log_arr['mark'] = $param['mark'];
|
||||||
|
$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, '申请成功');
|
||||||
|
}else{
|
||||||
|
return to_assign(0, '申请失败');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return to_assign(0, '余额不足');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return view();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同意提现
|
||||||
|
public function pass(){
|
||||||
|
$param = get_params();
|
||||||
|
if(empty($param['id'])){
|
||||||
|
return to_assign(0, '请选择要操作的数据');
|
||||||
|
}else{
|
||||||
|
// 启动事务
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
|
||||||
|
$find = Db::table('cms_admin_money_log')->where('id',$param['id'])->find();
|
||||||
|
if(empty($find)){
|
||||||
|
return to_assign(0, '数据未找到');
|
||||||
|
}
|
||||||
|
|
||||||
|
$money = Db::table('cms_admin_money')->where('id',$find['admin_id'])->find();
|
||||||
|
if($find['num'] > $money['money']){
|
||||||
|
return to_assign(0, '余额不足');
|
||||||
|
}
|
||||||
|
$data['status'] = 3;
|
||||||
|
$data['sh_admin_id'] = $this->uid;
|
||||||
|
Db::table('cms_admin_money_log')->where('id',$param['id'])->update($data);
|
||||||
|
// 扣除余额
|
||||||
|
Db::table('cms_admin_money')->where('id',$find['admin_id'])->dec('money',$find['num'])->update();
|
||||||
|
// 提交事务
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
return to_assign(0, '操作失败:' . $e->getMessage());
|
||||||
|
}
|
||||||
|
return to_assign(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拒绝提现
|
||||||
|
public function afuse(){
|
||||||
|
$param = get_params();
|
||||||
|
if(empty($param['id'])){
|
||||||
|
return to_assign(0, '请选择要操作的数据');
|
||||||
|
}else{
|
||||||
|
// 启动事务
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$find = Db::table('cms_admin_money_log')->where('id',$param['id'])->find();
|
||||||
|
if(empty($find)){
|
||||||
|
return to_assign(0, '数据未找到');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['status'] = 4;
|
||||||
|
$data['sh_admin_id'] = $this->uid;
|
||||||
|
$data['fail_msg'] = $param['fail_msg'];
|
||||||
|
Db::table('cms_admin_money_log')->where('id',$param['id'])->update($data);
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 回滚事务
|
||||||
|
Db::rollback();
|
||||||
|
return to_assign(0, '操作失败:' . $e->getMessage());
|
||||||
|
}
|
||||||
|
return to_assign(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
393
app/admin/view/store_product/tixian.html
Normal file
393
app/admin/view/store_product/tixian.html
Normal file
@ -0,0 +1,393 @@
|
|||||||
|
{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;vertical-align:top;">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">状态</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<select name="status" lay-filter="seleform">
|
||||||
|
<option value=""></option>
|
||||||
|
<option value="2">审核中</option>
|
||||||
|
<option value="3">提现成功</option>
|
||||||
|
<option value="4">提现拒绝</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</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="toolbarDemo">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="申请提现">申请提现</span>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/html" id="barDemo">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
{if {:session('gougu_admin')['group_access']==1}
|
||||||
|
<a class="layui-btn layui-btn-normal layui-btn-xs {{# if(d.status != 2){ }}layui-hide{{# } }}" lay-event="pass">已打款</a>
|
||||||
|
<a class="layui-btn layui-btn-danger layui-btn-xs {{# if(d.status != 2){ }}layui-hide{{# } }}" lay-event="afuse">拒绝提现</a>
|
||||||
|
{/if}
|
||||||
|
</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/tixian',
|
||||||
|
page: true,
|
||||||
|
limit: 20,
|
||||||
|
cellMinWidth: 300,
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: '编号',
|
||||||
|
align: 'center',
|
||||||
|
width: 80
|
||||||
|
},{
|
||||||
|
field: 'nickname',
|
||||||
|
title: '用户',
|
||||||
|
align: 'center',
|
||||||
|
width: 200,
|
||||||
|
},{
|
||||||
|
field: 'num',
|
||||||
|
title: '提现金额',
|
||||||
|
align: 'center',
|
||||||
|
width: 100
|
||||||
|
},{
|
||||||
|
field: 'mark',
|
||||||
|
title: '提现卡号',
|
||||||
|
align: 'center',
|
||||||
|
width:150,
|
||||||
|
|
||||||
|
},{
|
||||||
|
field: 'create_time',
|
||||||
|
title: '提现时间',
|
||||||
|
align: 'center',
|
||||||
|
width: 100
|
||||||
|
},{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
align: 'center',
|
||||||
|
width: 100,
|
||||||
|
templet: function (d)
|
||||||
|
{
|
||||||
|
switch (d.status) {
|
||||||
|
case 2:
|
||||||
|
return '审核中';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return '未通过';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return '提现完成';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
field: 'admin_user',
|
||||||
|
title: '审核用户',
|
||||||
|
align: 'center',
|
||||||
|
width:120,
|
||||||
|
templet: function (d)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(d.admin_user)
|
||||||
|
{
|
||||||
|
return d.admin_user;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d.status == 2)
|
||||||
|
{
|
||||||
|
return '等待审核';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '无';
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
field: 'fail_msg',
|
||||||
|
title: '拒绝原因',
|
||||||
|
align: 'center',
|
||||||
|
width:150,
|
||||||
|
},{
|
||||||
|
fixed: 'right',
|
||||||
|
field: 'right',
|
||||||
|
title: '操作',
|
||||||
|
toolbar: '#barDemo',
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
id: 'testReload' ,
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听表头工具栏事件
|
||||||
|
table.on('toolbar(store_product)', function(obj){
|
||||||
|
if (obj.event === 'add') {
|
||||||
|
tool.side('/admin/store_product/withdrawal');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 表格点击行自动选中 ==========================================================================
|
||||||
|
$(document).on("click",".layui-table-body table.layui-table tbody tr", function (e) {
|
||||||
|
var index = $(this).attr('data-index');
|
||||||
|
var tableBox = $(this).parents('.layui-table-box');
|
||||||
|
//存在固定列
|
||||||
|
if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
|
||||||
|
tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
|
||||||
|
} else {
|
||||||
|
tableDiv = tableBox.find(".layui-table-body.layui-table-main");
|
||||||
|
}
|
||||||
|
var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
|
||||||
|
if (checkCell.length > 0) {
|
||||||
|
checkCell.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 表格点击行出发复选框后,阻止向上冒泡===============================================================
|
||||||
|
$(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//监听表格行工具事件
|
||||||
|
table.on('tool(store_product)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
if (obj.event === 'afuse') {
|
||||||
|
layer.open({
|
||||||
|
type: 1,
|
||||||
|
area: ["400px", "200px"],
|
||||||
|
title: "拒绝提现",
|
||||||
|
content: "<input type=\"text\" name=\"fail_msg\" lay-verify=\"required\" placeholder=\"输入拒绝原因\" autocomplete=\"off\" class=\"layui-input\" id='fail_msg' min='1 '>",
|
||||||
|
btn: ['确定', '关闭'],
|
||||||
|
yes: function (index, layero) {
|
||||||
|
//ajax。必填参数,'options':请求参数,对象,'callback':成功回调函数
|
||||||
|
// 单击之后提交按钮不可选,防止重复提交
|
||||||
|
var DISABLED = 'layui-btn-disabled';
|
||||||
|
// 增加样式
|
||||||
|
$('.layui-layer-btn0').addClass(DISABLED);
|
||||||
|
// 增加属性
|
||||||
|
$('.layui-layer-btn0').attr('disabled', 'disabled');
|
||||||
|
let options = {
|
||||||
|
url: '/admin/store_product/afuse',
|
||||||
|
type: 'get',
|
||||||
|
data: {
|
||||||
|
id: obj.data.id,
|
||||||
|
fail_msg:$('#fail_msg').val(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let callback = function(res) {
|
||||||
|
if (res.code == 200) {
|
||||||
|
layer.msg('操作成功',{time:2000,icon:6});
|
||||||
|
// 关闭所有层
|
||||||
|
setTimeout(function () {
|
||||||
|
layer.closeAll();
|
||||||
|
}, 2000);
|
||||||
|
location.reload();
|
||||||
|
}else{
|
||||||
|
layer.msg(res.msg,{time:2000,icon:2});
|
||||||
|
$('.layui-layer-btn0').removeClass(DISABLED);
|
||||||
|
$('.layui-layer-btn0').removeAttr('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.ajax(options, callback);
|
||||||
|
},
|
||||||
|
cancel: function (layer_window) {
|
||||||
|
// 关闭弹出框页面
|
||||||
|
layer.close(layer_window);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (obj.event === 'edit') {
|
||||||
|
tool.side('/admin/store_product/edit?id='+obj.data.id);
|
||||||
|
}
|
||||||
|
else if (obj.event === 'pass') {
|
||||||
|
layer.confirm('确定要已打款吗?', {
|
||||||
|
icon: 3,
|
||||||
|
title: '提示'
|
||||||
|
}, function(index) {
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg,{time:2000,icon:6});
|
||||||
|
if(e.code == 200){
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.delete("/admin/store_product/pass", { id: data.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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
//商户商品分类菜单
|
||||||
|
$.ajax({
|
||||||
|
url: '/admin/product.StoreCategory/getAllList',
|
||||||
|
method: "get",
|
||||||
|
data: {},
|
||||||
|
success: function(res) {
|
||||||
|
if (res.code!==0)return ;
|
||||||
|
|
||||||
|
//高级演示 - 各种组合
|
||||||
|
dropdown.render({
|
||||||
|
elem: '#seleform'
|
||||||
|
,isAllowSpread: false //禁止菜单组展开收缩
|
||||||
|
,style: 'width: 200px' //定义宽度,默认自适应
|
||||||
|
,id: 'test777' //定义唯一索引
|
||||||
|
,title: 'title1'
|
||||||
|
,data: res.data
|
||||||
|
,click: function(item){
|
||||||
|
$('#seleform').text(item.title);
|
||||||
|
$('#seleform').css({color:'rgba(0,0,0,.85)'});
|
||||||
|
$('#store_cate').val(item.id);
|
||||||
|
|
||||||
|
active['reload'] ? active['reload'].call(this) : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail:function(){}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//基础效果
|
||||||
|
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}
|
||||||
|
<!-- /脚本 -->
|
128
app/admin/view/store_product/withdrawal.html
Normal file
128
app/admin/view/store_product/withdrawal.html
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
{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"}
|
||||||
|
<form class="layui-form p-4">
|
||||||
|
<h3 class="pb-3">申请提现</h3>
|
||||||
|
<table class="layui-table layui-table-form">
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">提现金额<font>*</font></td>
|
||||||
|
<td colspan="7"><input type="text" name="num" lay-verify="required|number" lay-reqText="请输入提现金额"
|
||||||
|
autocomplete="off" placeholder="请输入提现金额" class="layui-input"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<div class="pt-3">
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script src="/static/assets/js/xm-select.js"></script>
|
||||||
|
<script>
|
||||||
|
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||||||
|
var group_access = "{:session('gougu_admin')['group_access']}"
|
||||||
|
|
||||||
|
var multiple_images = [];
|
||||||
|
//单击图片删除图片 【注册全局函数】
|
||||||
|
function delMultipleImgs(this_img){
|
||||||
|
//获取下标
|
||||||
|
var subscript=$("#upload_box_thumb2 img").index(this_img);
|
||||||
|
//删除图片
|
||||||
|
this_img.remove();
|
||||||
|
//删除数组
|
||||||
|
multiple_images.splice(subscript, 1);
|
||||||
|
//重新排序
|
||||||
|
multiple_images.sort();
|
||||||
|
$('#upload_box_thumb2 input').attr('value', multiple_images);
|
||||||
|
//返回
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
function gouguInit() {
|
||||||
|
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
|
||||||
|
|
||||||
|
//上传缩略图
|
||||||
|
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_thumb = layui.upload.render({
|
||||||
|
elem: '#upload_btn_thumb2',
|
||||||
|
url: '/admin/api/upload',
|
||||||
|
multiple: true,
|
||||||
|
before: function(obj){
|
||||||
|
//预读本地文件示例,不支持ie8
|
||||||
|
obj.preview(function(index, file, result){
|
||||||
|
$('#upload_box_thumb2').append(`
|
||||||
|
<img src="${result}"
|
||||||
|
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
|
||||||
|
width="100" style="max-width: 100%; height:66px;" alt="${file.name}" onclick="delMultipleImgs(this)" title="点击删除"/>
|
||||||
|
`)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code == 1) {
|
||||||
|
return layer.msg('上传失败');
|
||||||
|
}
|
||||||
|
//上传成功
|
||||||
|
//追加图片成功追加文件名至图片容器
|
||||||
|
multiple_images.push(res.data.filepath);
|
||||||
|
$('#upload_box_thumb2 input').attr('value', multiple_images);
|
||||||
|
// $('#upload_box_thumb2 img').attr('src', res.data.filepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(webform)', function (data) {
|
||||||
|
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 200) {
|
||||||
|
tool.tabRefresh(71);
|
||||||
|
tool.sideClose(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.post('/admin/store_product/withdrawal', data.field, callback);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
@ -105,10 +105,9 @@ class PayNotify extends BaseController
|
|||||||
'paid_at' => $paid_at,
|
'paid_at' => $paid_at,
|
||||||
'product_id' => $post_id,
|
'product_id' => $post_id,
|
||||||
'number' => $payLog['number'],
|
'number' => $payLog['number'],
|
||||||
|
'cart_id' => $payLog['cart_id'],
|
||||||
];
|
];
|
||||||
Db::table('cms_store_product_order')->strict(false)->field(true)->insert($order_arr);
|
Db::table('cms_store_product_order')->strict(false)->field(true)->insert($order_arr);
|
||||||
// 减库存
|
|
||||||
Db::table('cms_store_product')->where('product_id', $post_id)->dec('stock',$payLog['number'])->update();
|
|
||||||
|
|
||||||
// 更新 PayLog, 这里的字段都是根据微信支付结果通知的字段设置的(https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_7&index=8)
|
// 更新 PayLog, 这里的字段都是根据微信支付结果通知的字段设置的(https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_7&index=8)
|
||||||
$pay_log = [
|
$pay_log = [
|
||||||
@ -129,6 +128,113 @@ class PayNotify extends BaseController
|
|||||||
'return_code' => $message['return_code'],
|
'return_code' => $message['return_code'],
|
||||||
];
|
];
|
||||||
Db::table('cms_store_product_paylog')->where('out_trade_no', $message['out_trade_no'])->update($pay_log);
|
Db::table('cms_store_product_paylog')->where('out_trade_no', $message['out_trade_no'])->update($pay_log);
|
||||||
|
// 写入商户余额表
|
||||||
|
if($payLog['cart_id']){ //购物车
|
||||||
|
$time = time();
|
||||||
|
if(strpos($payLog['cart_id'],',')){
|
||||||
|
$cart_ids = explode(',',$payLog['cart_id']);
|
||||||
|
foreach ($cart_ids as $k=>$v){
|
||||||
|
// 根据 id 查出价格
|
||||||
|
$where['cart_id'] = $v;
|
||||||
|
$cart = Db::table('cms_store_cart')->where($where)->lock(true)->find();
|
||||||
|
if (empty($cart)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 根据商品id获取商户admin_id
|
||||||
|
$wwww['product_id'] = $cart['product_id'];
|
||||||
|
$store_product = Db::table('cms_store_product')->where($wwww)->lock(true)->find();
|
||||||
|
if (empty($store_product)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 更新购物车
|
||||||
|
$c_data['is_pay'] = 1;
|
||||||
|
Db::table('cms_store_cart')->where($where)->update($c_data);
|
||||||
|
// 减库存
|
||||||
|
Db::table('cms_store_product')->where('product_id', $cart['product_id'])->dec('stock',$cart['cart_num'])->update();
|
||||||
|
|
||||||
|
// 写入后台余额表
|
||||||
|
$is_money = Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->lock(true)->find();
|
||||||
|
if($is_money){
|
||||||
|
$total_fee = bcmul((string)$store_product['price'],(string)$cart['cart_num']);
|
||||||
|
Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->inc('money',$total_fee)->update();
|
||||||
|
}else{
|
||||||
|
$total_fee = bcmul((string)$store_product['price'],(string)$cart['cart_num']);
|
||||||
|
$m_data['admin_id'] = $store_product['admin_id'];
|
||||||
|
$m_data['money'] = $total_fee;
|
||||||
|
Db::table('cms_admin_money')->insert($m_data);
|
||||||
|
}
|
||||||
|
//写入后台余额记录表
|
||||||
|
$log_arr['type'] = 0;
|
||||||
|
$log_arr['admin_id'] = $store_product['admin_id'];
|
||||||
|
$log_arr['num'] = $total_fee;
|
||||||
|
$log_arr['create_time'] = $time;
|
||||||
|
$log_arr['status'] = 1;
|
||||||
|
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$where['cart_id'] = $payLog['cart_id'];
|
||||||
|
$cart = Db::table('cms_store_cart')->where($where)->lock(true)->find();
|
||||||
|
if ($cart) {
|
||||||
|
// 根据商品id获取商户admin_id
|
||||||
|
$wwww['product_id'] = $cart['product_id'];
|
||||||
|
$store_product = Db::table('cms_store_product')->where($wwww)->lock(true)->find();
|
||||||
|
if ($store_product) {
|
||||||
|
// 更新购物车
|
||||||
|
$c_data['is_pay'] = 1;
|
||||||
|
Db::table('cms_store_cart')->where($where)->update($c_data);
|
||||||
|
// 减库存
|
||||||
|
Db::table('cms_store_product')->where('product_id', $cart['product_id'])->dec('stock',$cart['cart_num'])->update();
|
||||||
|
//写入后台余额表
|
||||||
|
$is_money = Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->lock(true)->find();
|
||||||
|
if($is_money){
|
||||||
|
$total_fee = bcmul((string)$store_product['price'],(string)$cart['cart_num']);
|
||||||
|
Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->inc('money',$total_fee)->update();
|
||||||
|
}else{
|
||||||
|
$total_fee = bcmul((string)$store_product['price'],(string)$cart['cart_num']);
|
||||||
|
$m_data['admin_id'] = $store_product['admin_id'];
|
||||||
|
$m_data['money'] = $total_fee;
|
||||||
|
Db::table('cms_admin_money')->insert($m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//写入后台余额记录表
|
||||||
|
$log_arr['type'] = 0;
|
||||||
|
$log_arr['admin_id'] = $store_product['admin_id'];
|
||||||
|
$log_arr['num'] = $total_fee;
|
||||||
|
$log_arr['create_time'] = $time;
|
||||||
|
$log_arr['status'] = 1;
|
||||||
|
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// 根据商品id获取商户admin_id
|
||||||
|
$www['product_id'] = $post_id;
|
||||||
|
$store_product = Db::table('cms_store_product')->where($www)->find();
|
||||||
|
if (!empty($store_product)) {
|
||||||
|
// 减库存
|
||||||
|
Db::table('cms_store_product')->where('product_id', $post_id)->dec('stock',$payLog['number'])->update();
|
||||||
|
//写入后台余额表
|
||||||
|
$is_money = Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->lock(true)->find();
|
||||||
|
if($is_money){
|
||||||
|
$total_fee = bcdiv($message['total_fee'],'100',2);
|
||||||
|
Db::table('cms_admin_money')->where('admin_id',$store_product['admin_id'])->inc('money',$total_fee)->update();
|
||||||
|
}else{
|
||||||
|
$total_fee = bcdiv($message['total_fee'],'100',2);
|
||||||
|
$m_data['admin_id'] = $store_product['admin_id'];
|
||||||
|
$m_data['money'] = $total_fee;
|
||||||
|
Db::table('cms_admin_money')->insert($m_data);
|
||||||
|
}
|
||||||
|
//写入后台余额记录表
|
||||||
|
$log_arr['type'] = 0;
|
||||||
|
$log_arr['admin_id'] = $store_product['admin_id'];
|
||||||
|
$log_arr['num'] = $total_fee;
|
||||||
|
$log_arr['create_time'] = time();
|
||||||
|
$log_arr['status'] = 1;
|
||||||
|
Db::table('cms_admin_money_log')->where('admin_id',$store_product['admin_id'])->strict(false)->field(true)->insert($log_arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果支付失败, 也更新 PayLog, 跟上面一样, 就是多了 error 信息
|
// 如果支付失败, 也更新 PayLog, 跟上面一样, 就是多了 error 信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user