初始化代码
This commit is contained in:
132
app/shop/controller/Admin.php
Normal file
132
app/shop/controller/Admin.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\BaseController;
|
||||
use think\App;
|
||||
use app\shop\model\Admin as Model;
|
||||
|
||||
use think\facade\Db;
|
||||
use think\facade\Lang;
|
||||
use think\Response;
|
||||
|
||||
class Admin extends BaseController
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $config_model;
|
||||
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-11 13:53
|
||||
* @功能说明:登陆
|
||||
*/
|
||||
public function login(){
|
||||
|
||||
// $input = $this->_input;
|
||||
|
||||
initLogin();
|
||||
|
||||
$input = json_decode( $this->request->getInput(), true );
|
||||
|
||||
//dump($input);exit;
|
||||
|
||||
$dis = [
|
||||
|
||||
// 'uniacid' => $this->_uniacid,
|
||||
|
||||
'username'=> $input['username']
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
return $this->error('该用户不存在', 400);
|
||||
|
||||
}
|
||||
|
||||
if($data['passwd']!=checkPass($input['passwd'])){
|
||||
|
||||
|
||||
return $this->error('密码错误', 400);
|
||||
}
|
||||
|
||||
$result['user'] = $data;
|
||||
|
||||
$result['token'] = uuid();
|
||||
|
||||
if (empty($result['token'])) {
|
||||
|
||||
return $this->error('系统错误', 400);
|
||||
}
|
||||
//添加缓存数据
|
||||
setUserForToken($result['token'], $data, 99999999);
|
||||
|
||||
return $this->success($result);
|
||||
|
||||
}
|
||||
|
||||
public function success ( $data, $code = 200 )
|
||||
{
|
||||
$result[ 'data' ] = $data;
|
||||
$result[ 'code' ] = $code;
|
||||
$result[ 'sign' ] = null;
|
||||
//复杂的签名
|
||||
// if(isset($this->_user['keys'])){
|
||||
// $result['sign'] = rsa2CreateSign($this->_user['keys'] ,json_encode($data));
|
||||
// }
|
||||
//简单的签名
|
||||
if ( !empty( $this->_token ) ) $result[ 'sign' ] = createSimpleSign( $this->_token, is_string( $data ) ? $data : json_encode( $data ) );
|
||||
|
||||
return $this->response( $result, 'json', $code );
|
||||
}
|
||||
|
||||
//返回错误数据
|
||||
public function error ( $msg, $code = 400 )
|
||||
{
|
||||
$result[ 'error' ] = Lang::get($msg);
|
||||
$result[ 'code' ] = $code;
|
||||
return $this->response( $result, 'json', 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出返回数据
|
||||
* @access protected
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param String $type 返回类型 JSON XML
|
||||
* @param integer $code HTTP状态码
|
||||
* @return Response
|
||||
*/
|
||||
protected function response ( $data, $type = 'json', $code = 200 )
|
||||
{
|
||||
return Response::create( $data, $type )->code( $code );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
446
app/shop/controller/AdminCap.php
Normal file
446
app/shop/controller/AdminCap.php
Normal file
@@ -0,0 +1,446 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\Order;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\User;
|
||||
use app\shop\model\Wallet;
|
||||
use longbingcore\wxcore\WxPay;
|
||||
use think\App;
|
||||
use app\shop\model\Cap as Model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminCap extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:43
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function capList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
if($input['status']==3){
|
||||
|
||||
$dis[] = ['a.status','in',[3,4]];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.status','=',$input['status']];
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.status','>',-1];
|
||||
}
|
||||
|
||||
$where = [] ;
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where [] = ['a.store_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where [] = ['a.name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where [] = ['a.mobile','like','%'.$input['name'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->adminDataList($dis,$where,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-30 16:50
|
||||
* @功能说明:财务中心列表
|
||||
*/
|
||||
public function financeList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
}else{
|
||||
|
||||
$date_model = new Date();
|
||||
|
||||
$start_time = $date_model->where(['uniacid'=>$this->_uniacid])->min('date_str');
|
||||
|
||||
$end_time = $date_model->where(['uniacid'=>$this->_uniacid])->max('date_str');
|
||||
|
||||
$end_time +=86399;
|
||||
}
|
||||
|
||||
$dis[] = ['a.status','in',[2,3]];
|
||||
|
||||
$where = [] ;
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where [] = ['a.store_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where [] = ['a.name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where [] = ['a.mobile','like','%'.$input['name'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->adminDataList($dis,$where,$input['limit']);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$order_model = new Order();
|
||||
|
||||
$wallet_model= new Wallet();
|
||||
|
||||
$refund_model= new RefundOrder();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
//总收入
|
||||
$v['total_cash'] = $order_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time);
|
||||
//单量
|
||||
$v['total_count'] = $order_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time,0);
|
||||
//总提现
|
||||
$v['wallet_cash'] = $wallet_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time);
|
||||
//提现笔数
|
||||
$v['wallet_count'] = $wallet_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time,0);
|
||||
//退款金额
|
||||
$v['refund_price'] = $refund_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time);
|
||||
|
||||
$v['refund_count'] = $refund_model->datePrice($start_time,$this->_uniacid,$v['id'],$end_time,0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:55
|
||||
* @功能说明:团长数量
|
||||
*/
|
||||
public function capCount(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
//所有
|
||||
$data['all_count'] = $this->model->where($dis)->where('status','>',-1)->count();
|
||||
//未授权
|
||||
$data['no_pass_count'] = $this->model->where($dis)->where('status','in',[3,4])->count();
|
||||
|
||||
$dis['status'] = 1;
|
||||
//申请中
|
||||
$data['apply_count'] = $this->model->where($dis)->count();
|
||||
|
||||
$dis['status'] = 2;
|
||||
//已授权
|
||||
$data['pass_count'] = $this->model->where($dis)->count();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:58
|
||||
* @功能说明:团长详情
|
||||
*/
|
||||
public function capInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 17:53
|
||||
* @功能说明:店铺下拉框
|
||||
*/
|
||||
public function capSelect(){
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','in',[2,3]];
|
||||
|
||||
$data = $this->model->where($dis)->field('id,store_name')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 15:03
|
||||
* @功能说明:修改团长
|
||||
*/
|
||||
public function capUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['sh_time'] = time();
|
||||
|
||||
$data = $this->model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 16:04
|
||||
* @功能说明:楼长提现列表
|
||||
*/
|
||||
public function walletList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
if(!empty($input['order_code'])){
|
||||
|
||||
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis[] = ['a.status','=',$input['status']];
|
||||
}
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$data = $wallet_model->adminList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-24 17:04
|
||||
* @功能说明:通过审核
|
||||
*/
|
||||
public function walletPass(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$info = $wallet_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($info['status']==2){
|
||||
|
||||
$this->errorMsg('已同意打款');
|
||||
}
|
||||
|
||||
if($info['status']==3){
|
||||
|
||||
$this->errorMsg('已拒绝打款');
|
||||
}
|
||||
|
||||
$update = [
|
||||
|
||||
'cash_time' => time(),
|
||||
|
||||
//'text' => !empty($input['text'])?$input['text']:'',
|
||||
|
||||
'status' => 2,
|
||||
|
||||
'online' => $input['online'],
|
||||
|
||||
'pay_cash' => $info['true_cash']
|
||||
];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $wallet_model->dataUpdate(['id'=>$input['id'],'status'=>1],$update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('打款失败');
|
||||
|
||||
}
|
||||
//线上转账
|
||||
if($input['online']==1){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$openid = $user_model->where(['id'=>$info['user_id']])->value('openid');
|
||||
|
||||
if(empty($openid)){
|
||||
|
||||
return $this->error('用户信息错误,未获取到openid');
|
||||
}
|
||||
//微信相关模型
|
||||
$wx_pay = new WxPay($this->_uniacid);
|
||||
//微信提现
|
||||
$res = $wx_pay->crteateMchPay($this->payConfig(),$openid,$update['pay_cash']);
|
||||
|
||||
if($res['result_code']=='SUCCESS'&&$res['return_code']=='SUCCESS'){
|
||||
|
||||
if(!empty($res['payment_no'])){
|
||||
|
||||
$wallet_model->dataUpdate(['id'=>$input['id']],['payment_no'=>$res['payment_no']]);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return $this->error(!empty($res['err_code_des'])?$res['err_code_des']:'你还未该权限');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 15:03
|
||||
* @功能说明:决绝提现
|
||||
*/
|
||||
public function walletNoPass(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$info = $wallet_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($info['status']==2){
|
||||
|
||||
$this->errorMsg('已同意打款');
|
||||
}
|
||||
|
||||
if($info['status']==3){
|
||||
|
||||
$this->errorMsg('已拒绝打款');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
|
||||
$update = [
|
||||
|
||||
'cash_time' => time(),
|
||||
|
||||
//'text' => !empty($input['text'])?$input['text']:'',
|
||||
|
||||
'status' => 3,
|
||||
|
||||
];
|
||||
|
||||
$res = $wallet_model->dataUpdate(['id'=>$input['id'],'status'=>1],$update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('打款失败');
|
||||
|
||||
}
|
||||
|
||||
$cap_info = $this->model->dataInfo(['id'=>$info['cap_id']]);
|
||||
|
||||
$res = $this->model->dataUpdate(['id'=>$info['cap_id']],['cap_cash'=>$cap_info['cap_cash']+$info['apply_cash']]);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('打款失败');
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
299
app/shop/controller/AdminExcel.php
Normal file
299
app/shop/controller/AdminExcel.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Cap;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\OrderAddress;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\Wallet;
|
||||
use longbingcore\wxcore\Excel;
|
||||
use think\App;
|
||||
use app\shop\model\Order as Model;
|
||||
|
||||
|
||||
class AdminExcel extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $order_goods_model;
|
||||
|
||||
protected $refund_order_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
$this->order_goods_model = new OrderGoods();
|
||||
|
||||
$this->refund_order_model = new RefundOrder();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:43
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function orderList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
//时间搜素
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//商品名字搜索
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
}
|
||||
//手机号搜索
|
||||
if(!empty($input['mobile'])){
|
||||
|
||||
$dis[] = ['d.mobile','like','%'.$input['mobile'].'%'];
|
||||
}
|
||||
//订单状态搜索
|
||||
if(!empty($input['pay_type'])){
|
||||
|
||||
$dis[] = ['a.pay_type','=',$input['pay_type']];
|
||||
}
|
||||
//店铺名字搜索
|
||||
if(!empty($input['store_id'])){
|
||||
|
||||
$dis[] = ['a.cap_id','=',$input['store_id']];
|
||||
}
|
||||
|
||||
if(!empty($input['order_code'])){
|
||||
|
||||
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->adminDataSelect($dis,$input['limit']);
|
||||
|
||||
$name = '订单列表';
|
||||
|
||||
$header=[
|
||||
'订单ID',
|
||||
'商品名',
|
||||
'商品价格',
|
||||
'商品规格',
|
||||
'商品数量',
|
||||
'下单人',
|
||||
'手机号',
|
||||
'实收金额',
|
||||
'系统订单号',
|
||||
'付款订单号',
|
||||
'下单时间',
|
||||
'支付方式',
|
||||
'配送方式',
|
||||
'核销人',
|
||||
'状态',
|
||||
];
|
||||
|
||||
$new_data = [];
|
||||
|
||||
foreach ($data as $v){
|
||||
|
||||
$info = array();
|
||||
|
||||
$info[] = $v['id'];
|
||||
|
||||
$info[] = $v['goods_name'];
|
||||
|
||||
$info[] = $v['goods_price'];
|
||||
|
||||
$info[] = $v['spe_name'];
|
||||
|
||||
$info[] = $v['goods_num'];
|
||||
|
||||
$info[] = $v['store_name'];
|
||||
|
||||
$info[] = $v['name'];
|
||||
|
||||
$info[] = $v['user_name'];
|
||||
|
||||
$info[] = $v['mobile'];
|
||||
|
||||
$info[] = $v['pay_price'];
|
||||
|
||||
$info[] = $v['order_code'];
|
||||
|
||||
$info[] = $v['transaction_id'];
|
||||
|
||||
$info[] = $v['create_time']?date('Y-m-d H:i:s',$v['create_time']):'暂无信息';
|
||||
|
||||
$info[] = !empty($v['balance'])?'余额支付':'微信支付';
|
||||
|
||||
$info[] = $v['send_type']==1?'自提':'快递';
|
||||
|
||||
$info[] = $v['send_type']==1?'自提':'快递';
|
||||
|
||||
$info[] = $this->orderStatusText($v['pay_type']);
|
||||
|
||||
$info[] = $v['hx_user_name'];
|
||||
|
||||
$new_data[] = $info;
|
||||
}
|
||||
|
||||
$excel = new Excel();
|
||||
|
||||
$excel->excelExport($name,$header,$new_data,'',2);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-30 16:32
|
||||
* @功能说明:
|
||||
*/
|
||||
public function orderStatusText($status){
|
||||
|
||||
switch ($status){
|
||||
|
||||
case 1:
|
||||
return '待支付';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return '已支付';
|
||||
|
||||
break;
|
||||
|
||||
case 7:
|
||||
return '已完成';
|
||||
|
||||
break;
|
||||
|
||||
case -1:
|
||||
return '已取消';
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 13:37
|
||||
* @功能说明:财务数据统计导出
|
||||
*/
|
||||
public function dateCount(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$cap_id = $input['cap_id'];
|
||||
|
||||
$date_model = new Date();
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$cap_model = new Cap();
|
||||
|
||||
$date_model->dataInit($this->_uniacid);
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
//时间搜素
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['date_str','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
$date_list = $date_model->dataList($dis,100000);
|
||||
//店铺名字
|
||||
$store_name = $cap_model->where(['id'=>$cap_id])->value('store_name');
|
||||
//开始时间结束时间
|
||||
if(!empty($start_time)){
|
||||
|
||||
$date_list['start_time'] = $start_time;
|
||||
|
||||
$date_list['end_time'] = $end_time;
|
||||
|
||||
}else{
|
||||
|
||||
$date_list['start_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->min('date_str');
|
||||
|
||||
$date_list['end_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->max('date_str');
|
||||
|
||||
}
|
||||
|
||||
if(!empty($date_list['data'])){
|
||||
|
||||
foreach ($date_list['data'] as $k=>$v){
|
||||
//订单金额
|
||||
$date_list['data'][$k]['order_price'] = $this->model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
//退款金额
|
||||
$date_list['data'][$k]['refund_price'] = $this->refund_order_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
//提现金额
|
||||
$date_list['data'][$k]['wallet_price'] = $wallet_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$name = $store_name.'财务报表';
|
||||
|
||||
$header=[
|
||||
'收支时间',
|
||||
'订单收入',
|
||||
'订单退款',
|
||||
'提现(元)',
|
||||
];
|
||||
|
||||
$new_data = [];
|
||||
|
||||
foreach ($date_list['data'] as $v){
|
||||
|
||||
$info = array();
|
||||
|
||||
$info[] = $v['date'];
|
||||
|
||||
$info[] = $v['order_price'];
|
||||
|
||||
$info[] = $v['refund_price'];
|
||||
|
||||
$info[] = $v['wallet_price'];
|
||||
|
||||
$new_data[] = $info;
|
||||
}
|
||||
|
||||
$excel = new Excel();
|
||||
|
||||
$excel->excelExport($name,$header,$new_data);
|
||||
|
||||
return $this->success($date_list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
173
app/shop/controller/AdminFreight.php
Normal file
173
app/shop/controller/AdminFreight.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\FreightConfig;
|
||||
use app\shop\model\FreightProvince;
|
||||
use app\shop\model\FreightTemplate;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\Integral;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\Wallet;
|
||||
use think\App;
|
||||
use app\shop\model\User as Model;
|
||||
|
||||
|
||||
class AdminFreight extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $config_model;
|
||||
|
||||
protected $province_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new FreightTemplate();
|
||||
|
||||
$this->config_model = new FreightConfig();
|
||||
|
||||
$this->province_model = new FreightProvince();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:43
|
||||
* @功能说明:模版列表
|
||||
*/
|
||||
public function tmplList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
if(isset($input['status'])){
|
||||
|
||||
$dis[] = ['status','=',$input['status']];
|
||||
}else{
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
}
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:43
|
||||
* @功能说明:模版列表
|
||||
*/
|
||||
public function tmplSelect(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->where($dis)->order('id desc')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 15:47
|
||||
* @功能说明:添加运费模版
|
||||
*/
|
||||
public function tmplAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->tmplAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:44
|
||||
* @功能说明:编辑运费模版
|
||||
*/
|
||||
public function tmplUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->tmplUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:45
|
||||
* @功能说明:模版详情
|
||||
*/
|
||||
public function tmplInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
613
app/shop/controller/AdminGoods.php
Normal file
613
app/shop/controller/AdminGoods.php
Normal file
@@ -0,0 +1,613 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\farm\model\Farmer;
|
||||
use app\farm\model\LandCate;
|
||||
use app\farm\model\ShopGoods;
|
||||
use app\member\model\DiscountGoods;
|
||||
use app\shop\model\FreightTemplate;
|
||||
use app\shop\model\GoodsSpePrice;
|
||||
use app\shop\model\ShopGoodsCate;
|
||||
use app\shop\model\ShopGoodsSpe;
|
||||
use think\App;
|
||||
use app\shop\model\Goods as Model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminGoods extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $cate_model;
|
||||
|
||||
protected $spe_model;
|
||||
|
||||
protected $spe_price_model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new ShopGoods();
|
||||
|
||||
$this->cate_model = new ShopGoodsCate();
|
||||
|
||||
$this->spe_model = new ShopGoodsSpe();
|
||||
|
||||
$this->spe_price_model = new GoodsSpePrice();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:01
|
||||
* @功能说明:商品分类列表
|
||||
*/
|
||||
public function goodsCateList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->cate_model->dataList($dis,$input['limit']);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$farmer_model = new Farmer();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['farmer_name'] = $farmer_model->where('id','in',$v['store'])->column('title');
|
||||
|
||||
$v['farmer_name'] = implode(',',$v['farmer_name']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:17
|
||||
* @功能说明:添加分类
|
||||
*/
|
||||
public function goodsCateAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$data = $this->cate_model->dataAdd($input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:18
|
||||
* @功能说明:编辑分类
|
||||
*/
|
||||
public function goodsCateUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$data = $this->cate_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:18
|
||||
* @功能说明:编辑分类
|
||||
*/
|
||||
public function goodsCateInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$data = $this->cate_model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 17:58
|
||||
* @功能说明:分类下拉框
|
||||
*/
|
||||
public function goodsCateSelect(){
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
|
||||
];
|
||||
|
||||
$data = $this->cate_model->where($dis)->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-13 17:21
|
||||
* @功能说明:商品列表
|
||||
*/
|
||||
public function goodsList(){
|
||||
|
||||
$input= $this->_param;
|
||||
|
||||
$dis[]= ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$dis[] = ['a.goods_name','like',"%".$input['name']."%"];
|
||||
}
|
||||
|
||||
if(!empty($input['cate_id'])){
|
||||
|
||||
$dis[] = ['c.cate_id','=',$input['cate_id']];
|
||||
}
|
||||
|
||||
if(!empty($input['store_id'])){
|
||||
|
||||
$dis[] = ['b.store_id','=',$input['store_id']];
|
||||
}
|
||||
|
||||
$sale_type = $input['type']==2?0:1;
|
||||
|
||||
$sale_out_goods = $this->spe_price_model->getSellOut($this->_uniacid,$sale_type);
|
||||
|
||||
switch ($input['type']){
|
||||
|
||||
case 1:
|
||||
$dis[] = ['a.status','=',1];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$dis[]= ['a.status','>',-1];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$dis[] = ['a.status','=',0];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$dis[] = ['a.id','in',$sale_out_goods];
|
||||
|
||||
$data = $this->model->goodsList($dis,$this->_input['limit']);
|
||||
|
||||
$farmer_model = new Farmer();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$cate_name = $this->cate_model->where('id','in',$v['cate_id'])->column('title');
|
||||
|
||||
$v['cate_name'] = implode(',',$cate_name);
|
||||
|
||||
$store_name = $farmer_model->where('id','in',$v['store'])->column('title');
|
||||
|
||||
$v['store_name'] = implode(',',$store_name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//销售中
|
||||
$data['sale_ing'] = $this->model->saleIngCount($this->_uniacid);
|
||||
//售罄
|
||||
$data['sale_out'] = $this->model->saleIngCount($this->_uniacid,2);
|
||||
//下架
|
||||
$data['sale_end'] = $this->model->saleIngCount($this->_uniacid,3);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:33
|
||||
* @功能说明:添加商品
|
||||
*/
|
||||
public function goodsAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$goods_id = $this->model->dataAdd($input);
|
||||
|
||||
$spe_arr = $this->goodsSpeAdd($input['specsItem'],$goods_id);
|
||||
|
||||
$res = $this->goodsSpePriceAdd($input['specsTable'],$goods_id,$spe_arr);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-13 17:50
|
||||
* @功能说明:修改商品
|
||||
*/
|
||||
public function goodsUpdate(){
|
||||
|
||||
$input= $this->_input;
|
||||
|
||||
$dis = is_array($input['id'])? ['id','in',$input['id']]:['id' =>$input['id']];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$this->model->goodsUpdate($dis,$input);
|
||||
|
||||
$this->spe_model->goodsSpeUpdate(['uniacid'=>$this->_uniacid,'goods_id'=>$input['id']],['status'=>-1]);
|
||||
|
||||
$this->spe_price_model->goodsSpePriceUpdate(['uniacid'=>$this->_uniacid,'goods_id'=>$input['id']],['status'=>-1]);
|
||||
|
||||
$spe_arr = $this->goodsSpeAdd($input['specsItem'],$input['id']);
|
||||
|
||||
$res = $this->goodsSpePriceAdd($input['specsTable'],$input['id'],$spe_arr);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-09 17:49
|
||||
* @功能说明:商品复制
|
||||
*/
|
||||
public function goodsCopy(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$data = $this->model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
$data['goods_name'] = $input['goods_name'];
|
||||
|
||||
$data['store'] = $input['store'];
|
||||
|
||||
unset($data['id']);
|
||||
|
||||
unset($data['show_price']);
|
||||
|
||||
unset($data['show_init_price']);
|
||||
|
||||
unset($data['all_stock']);
|
||||
|
||||
unset($data['all_sale_count']);
|
||||
|
||||
$spe_info = $this->goodsSpeList($input['id']);
|
||||
|
||||
$data['specsItem'] = $spe_info['text'];
|
||||
|
||||
$data['specsTable'] = $spe_info['price'];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
|
||||
$goods_id = $this->model->dataAdd($data);
|
||||
|
||||
$spe_arr = $this->goodsSpeAdd($data['specsItem'],$goods_id,1);
|
||||
|
||||
$res = $this->goodsSpePriceAdd($data['specsTable'],$goods_id,$spe_arr);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-21 11:21
|
||||
* @功能说明:分类详情
|
||||
*/
|
||||
public function goodsInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$res['goods_info'] = $this->model->dataInfo($dis);
|
||||
|
||||
$res['spe_info'] = $this->goodsSpeList($input['id']);
|
||||
|
||||
$freightTemplate_model = new FreightTemplate();
|
||||
|
||||
$res['goods_info']['send_template_type'] = $freightTemplate_model->where(['id'=>$res['goods_info']['send_tmpl_id']])->value('type');
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品规格
|
||||
*/
|
||||
public function goodsSpeList($goods_id){
|
||||
|
||||
$dis['goods_id'] = $goods_id;
|
||||
|
||||
$dis['status'] = 1;
|
||||
|
||||
$data['text'] = $this->spe_model->goodsSpe($dis);
|
||||
|
||||
$data['price'] = $this->spe_price_model->goodsSpePrice($dis);
|
||||
|
||||
if(!empty($data['price'])){
|
||||
|
||||
foreach ($data['price'] as &$v){
|
||||
|
||||
$v['title'] = $v['spe_name_text'];
|
||||
|
||||
$v['true_id'] = $v['id'];
|
||||
|
||||
$v['id'] = implode(',',$v['spe_array_text']);
|
||||
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-26 10:09
|
||||
* @功能说明:列表页修改商品库存
|
||||
*/
|
||||
public function updateSpe(){
|
||||
|
||||
$input= $this->_input;
|
||||
|
||||
$input= $input['stock'];
|
||||
|
||||
if(!empty($input)&&!is_array($input)){
|
||||
|
||||
$this->errorMsg('数据错误');
|
||||
}
|
||||
|
||||
foreach ($input as $value){
|
||||
|
||||
$this->spe_price_model->goodsSpePriceUpdate(['id'=>$value['id']],['stock'=>$value['stock']]);
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-28 10:33
|
||||
* @功能说明:修改商品基本的参数
|
||||
*/
|
||||
public function goodsBasicUpdate(){
|
||||
|
||||
$input= $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$res = $this->model->goodsUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下架删除商品
|
||||
*/
|
||||
public function goodsStatusUpdate(){
|
||||
|
||||
$input= $this->_input;
|
||||
|
||||
if(isset($input['status'])){
|
||||
|
||||
$data = ['status'=>$input['status']];
|
||||
|
||||
}else{
|
||||
|
||||
$data = ['index_show'=>$input['index_show']];
|
||||
|
||||
}
|
||||
$res = $this->model->where('id','in',$input['id'])->update($data);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $goods_id
|
||||
* @return array
|
||||
* 添加多规格
|
||||
*/
|
||||
public function goodsSpeAdd($data,$goods_id,$is_copy=0){
|
||||
/**
|
||||
* 循环判断是否存在多个规格名添加图片的问题
|
||||
* @date 2020/5/14 10:42 --lichuanming
|
||||
*/
|
||||
$isimg_count = 0;
|
||||
foreach ($data as $item ){
|
||||
if($item['is_img'] == 1){
|
||||
$isimg_count++;
|
||||
}
|
||||
}
|
||||
if($isimg_count > 1){
|
||||
return $this->error('当前已有规格名添加了图片,继续添加则需取消上一个规格名的图片勾选');
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
if(!empty($data)){
|
||||
foreach ($data as $v){
|
||||
$is_img = $v['is_img']?$v['is_img']:0; #@date 2020/5/14 10:42 --lichuanming
|
||||
if(strlen($v['pid'])>10||$is_copy==1){
|
||||
$pid = $this->spe_model->goodsSpeAdd(['uniacid'=>$this->_uniacid,'goods_id'=>$goods_id,'title'=>$v['title'],'is_img'=>$is_img]);
|
||||
}else{
|
||||
$this->spe_model->goodsSpeUpdate(['id'=>$v['id']],['status'=>1,'title'=>$v['title'],'is_img'=>$is_img]);
|
||||
$pid = $v['id'];
|
||||
}
|
||||
if(!empty($v['cate'])){
|
||||
foreach ($v['cate'] as $value){
|
||||
$image = $is_img?$value['image']:''; #@date 2020/5/14 10:42 --lichuanming
|
||||
|
||||
if(strlen($value['id'])>10||$is_copy==1) {
|
||||
$id = $this->spe_model->goodsSpeAdd(['uniacid' => $this->_uniacid, 'goods_id' => $goods_id, 'title' => $value['title'], 'pid' => $pid,'is_img'=>$is_img,'image'=>$image]);
|
||||
}else{
|
||||
$this->spe_model->goodsSpeUpdate(['id'=>$value['id']],['status'=>1,'title'=>$value['title'],'is_img'=>$is_img,'image'=>$image]);
|
||||
$id = $value['id'];
|
||||
}
|
||||
$arr[$value['id']] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dump($data,$arr);exit;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $good_id
|
||||
* @param $arr
|
||||
* @return int|string
|
||||
* 添加多规格价格
|
||||
*/
|
||||
public function goodsSpePriceAdd($data,$good_id,$arr){
|
||||
if(!empty($data)){
|
||||
foreach ($data as $v){
|
||||
if (strlen($v['price'])>8||strlen($v['original_price'])>8){
|
||||
|
||||
// $this->errorMsg('价格最多8位');
|
||||
|
||||
}
|
||||
|
||||
$pid = explode(',',$v['id']);
|
||||
$spe_id = [];
|
||||
if(empty($arr)){
|
||||
$this->errorMsg('规格不正确,请删除错误规格,重新编辑');
|
||||
}
|
||||
foreach ($pid as $value){
|
||||
if(!key_exists($value,$arr)){
|
||||
$this->errorMsg('规格不正确,请删除错误规格,重新编辑');
|
||||
}
|
||||
$spe_id[] = $arr[$value];
|
||||
}
|
||||
$spe_price_id = implode('-',$spe_id);
|
||||
|
||||
$ins['uniacid'] = $this->_uniacid;
|
||||
|
||||
$ins['goods_id']= $good_id;
|
||||
|
||||
$ins['spe_id_1']= $spe_price_id;
|
||||
|
||||
$ins['price'] = $v['price'];
|
||||
|
||||
$ins['stock'] = $v['stock'];
|
||||
|
||||
// $ins['alert_stock'] = $v['alert_stock'];
|
||||
|
||||
$ins['status'] = 1;
|
||||
//原价
|
||||
$ins['original_price'] = !empty($v['original_price'])?$v['original_price']:0;
|
||||
//成本价
|
||||
$ins['cost_price'] = !empty($v['cost_price'])?$v['cost_price']:0;
|
||||
|
||||
$spe_price = $this->spe_price_model->singeSpePrice(['goods_id'=>$good_id,'spe_id_1'=>$spe_price_id,'uniacid'=>$this->_uniacid]);
|
||||
|
||||
if(empty($spe_price)) {
|
||||
|
||||
$res = $this->spe_price_model->goodsSpePriceAdd($ins);
|
||||
|
||||
}else{
|
||||
|
||||
$res = $this->spe_price_model->goodsSpePriceUpdate(['id'=>$spe_price['id']],$ins);
|
||||
}
|
||||
}
|
||||
}
|
||||
return !empty($res)?$res:1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
579
app/shop/controller/AdminMark.php
Normal file
579
app/shop/controller/AdminMark.php
Normal file
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\farm\model\ShopGoods;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\Integral;
|
||||
use app\shop\model\IntegralList;
|
||||
use app\shop\model\LuckDraw;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\SeckillConfig;
|
||||
use app\shop\model\SeckillGoods;
|
||||
use app\shop\model\SeckillList;
|
||||
use app\shop\model\Signin;
|
||||
use app\shop\model\Wallet;
|
||||
use think\App;
|
||||
use app\shop\model\User as Model;
|
||||
|
||||
|
||||
class AdminMark extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $order_goods_model;
|
||||
|
||||
protected $refund_order_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new IntegralList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:43
|
||||
* @功能说明:积分列表
|
||||
*/
|
||||
public function integralList(){
|
||||
|
||||
$this->model->initAtv();
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.status','>',-1];
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['b.name','like','%'.$input['goods_name'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['atv_status'])){
|
||||
|
||||
$dis[] = ['a.atv_status','=',$input['atv_status']];
|
||||
}
|
||||
|
||||
$data = $this->model->dataGoodsList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 11:58
|
||||
* @功能说明:添加积分商城规则
|
||||
*/
|
||||
//[{"spe_id":1,"stock":1,"price":1,"integral":1}]
|
||||
public function integralAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataAdd($input);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:28
|
||||
* @功能说明:积分活动详情
|
||||
*/
|
||||
public function integralInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$data['goods_name'] = $goods_model->where(['id'=> $data['goods_id']])->value('goods_name');
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:30
|
||||
* @功能说明:编辑积分规则
|
||||
*/
|
||||
public function integralUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataUpdate(['id'=>$input['id']],$input);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 11:54
|
||||
* @功能说明:签到详情
|
||||
*/
|
||||
public function signInfo(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$sign_model = new Signin();
|
||||
|
||||
$data = $sign_model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 11:54
|
||||
* @功能说明:签到编辑
|
||||
*/
|
||||
public function signUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$sign_model = new Signin();
|
||||
|
||||
$data = $sign_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:17
|
||||
* @功能说明:抽奖活动列表
|
||||
*/
|
||||
public function luckList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['atv_status'])){
|
||||
|
||||
$dis[] = ['atv_status','=',$input['atv_status']];
|
||||
|
||||
}
|
||||
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
$luck_model->initAtv();
|
||||
|
||||
$data = $luck_model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:18
|
||||
* @功能说明:添加抽奖
|
||||
*/
|
||||
public function luckAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
if(!empty($input['data'])){
|
||||
|
||||
$balance = array_sum(array_column($input['data'],'balane'));
|
||||
|
||||
if($balance>100||$balance<0){
|
||||
|
||||
$this->errorMsg('累计中奖率在0-100%之间');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$check = $luck_model->checkTime($input);
|
||||
|
||||
if(!empty($check['code'])){
|
||||
|
||||
$this->errorMsg($check['msg']);
|
||||
|
||||
}
|
||||
|
||||
$res = $luck_model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:18
|
||||
* @功能说明:添加抽奖
|
||||
*/
|
||||
public function luckUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
if(!empty($input['data'])){
|
||||
|
||||
$balance = array_sum(array_column($input['data'],'balane'));
|
||||
|
||||
if($balance>100||$balance<0){
|
||||
|
||||
$this->errorMsg('累计中奖率在0-100%之间');
|
||||
}
|
||||
|
||||
}
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
$check = $luck_model->checkTime($input);
|
||||
|
||||
if(!empty($check['code'])){
|
||||
|
||||
$this->errorMsg($check['msg']);
|
||||
|
||||
}
|
||||
|
||||
$res = $luck_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:19
|
||||
* @功能说明:抽奖详情
|
||||
*/
|
||||
public function luckInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
$res = $luck_model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:17
|
||||
* @功能说明:秒杀活动列表
|
||||
*/
|
||||
public function killList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['atv_status'])){
|
||||
|
||||
$dis[] = ['atv_status','=',$input['atv_status']];
|
||||
}
|
||||
|
||||
$luck_model = new SeckillList();
|
||||
|
||||
$luck_model->initAtv();
|
||||
|
||||
$data = $luck_model->dataList($dis,$input['limit']);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['order_price'] = 0;
|
||||
|
||||
$v['order_count'] = 0;
|
||||
|
||||
$v['user_count'] = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:18
|
||||
* @功能说明:添加秒杀
|
||||
*/
|
||||
public function killAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$luck_model = new SeckillList();
|
||||
|
||||
$res = $luck_model->atvCheck($input);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
$res = $luck_model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:18
|
||||
* @功能说明:编辑秒杀
|
||||
*/
|
||||
public function killUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$luck_model = new SeckillList();
|
||||
|
||||
if(isset($input['start_time'])&&isset($input['end_time'])){
|
||||
|
||||
$res = $luck_model->atvCheck($input);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$res = $luck_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:19
|
||||
* @功能说明:秒杀详情
|
||||
*/
|
||||
public function killInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$luck_model = new SeckillList();
|
||||
|
||||
$res = $luck_model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 14:22
|
||||
* @功能说明:添加秒杀商品
|
||||
*/
|
||||
public function addKillGoods(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$luck_model = new SeckillList();
|
||||
|
||||
$res = $luck_model->updateSome($input['atv_id'],$this->_uniacid,$input['goods_info'],$input['goods_id']);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 14:58
|
||||
* @功能说明:秒杀商品列表
|
||||
*/
|
||||
public function killGoodsList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$goods_model = new SeckillGoods();
|
||||
|
||||
$dis[] = ['a.atv_id','=',$input['atv_id']];
|
||||
|
||||
$dis[] = ['b.status','=',1];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
$dis[] = ['d.status','=',2];
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['b.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
$data = $goods_model->goodsList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 15:13
|
||||
* @功能说明:删除秒杀商品
|
||||
*/
|
||||
public function killGoodsDel(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$goods_model = new SeckillGoods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$res = $goods_model->where($dis)->delete();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 15:23
|
||||
* @功能说明:秒杀商品详情
|
||||
*/
|
||||
public function killGoodsInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$goods_model = new SeckillGoods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'atv_id' => $input['atv_id'],
|
||||
|
||||
'goods_id'=> $input['goods_id'],
|
||||
];
|
||||
|
||||
$res = $goods_model->dataInfo($dis);
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$res['goods_name'] = $goods_model->where(['id'=> $input['goods_id']])->value('goods_name');
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
174
app/shop/controller/AdminMember.php
Normal file
174
app/shop/controller/AdminMember.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\FreightConfig;
|
||||
use app\shop\model\FreightProvince;
|
||||
use app\shop\model\FreightTemplate;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\Integral;
|
||||
use app\shop\model\Member;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\Wallet;
|
||||
use think\App;
|
||||
use app\shop\model\User as Model;
|
||||
|
||||
|
||||
class AdminMember extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $config_model;
|
||||
|
||||
protected $province_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Member();
|
||||
|
||||
$this->config_model = new FreightConfig();
|
||||
|
||||
$this->province_model = new FreightProvince();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:43
|
||||
* @功能说明:会员列表
|
||||
*/
|
||||
public function memberList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
if(isset($input['status'])){
|
||||
|
||||
$dis[] = ['status','=',$input['status']];
|
||||
}else{
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
}
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:43
|
||||
* @功能说明:会员列表
|
||||
*/
|
||||
public function memberSelect(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->where($dis)->order('id desc')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 15:47
|
||||
* @功能说明:添加会员
|
||||
*/
|
||||
public function memberAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:44
|
||||
* @功能说明:编辑会员
|
||||
*/
|
||||
public function memberUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:45
|
||||
* @功能说明:会员详情
|
||||
*/
|
||||
public function memberInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
369
app/shop/controller/AdminOrder.php
Normal file
369
app/shop/controller/AdminOrder.php
Normal file
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Cap;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\MsgConfig;
|
||||
use app\shop\model\OrderAddress;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\RefundOrderGoods;
|
||||
use app\shop\model\Wallet;
|
||||
use think\App;
|
||||
use app\shop\model\Order as Model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminOrder extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $order_goods_model;
|
||||
|
||||
protected $refund_order_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
$this->order_goods_model = new OrderGoods();
|
||||
|
||||
$this->refund_order_model = new RefundOrder();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:43
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function orderList(){
|
||||
|
||||
//超时自动取消订单
|
||||
$this->model->autoCancelOrder($this->_uniacid);
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
//时间搜素
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//商品名字搜索
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
}
|
||||
//手机号搜索
|
||||
if(!empty($input['mobile'])){
|
||||
|
||||
$dis[] = ['d.mobile','like','%'.$input['mobile'].'%'];
|
||||
}
|
||||
//订单状态搜索
|
||||
if(!empty($input['pay_type'])){
|
||||
|
||||
$dis[] = ['a.pay_type','=',$input['pay_type']];
|
||||
}
|
||||
|
||||
if(!empty($input['order_code'])){
|
||||
|
||||
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['send_type'])){
|
||||
|
||||
$dis[] = ['a.send_type','=',$input['send_type']];
|
||||
}
|
||||
|
||||
$data = $this->model->adminDataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 09:39
|
||||
* @功能说明:修改订单
|
||||
*/
|
||||
public function orderGoodsSend(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$update = [
|
||||
//快递公司
|
||||
'express_company' => $input['express_company'],
|
||||
//快递电话
|
||||
'express_mobile' => $input['express_mobile'],
|
||||
//快递单号
|
||||
'express_code' => $input['express_code'],
|
||||
|
||||
'send_time' => time(),
|
||||
|
||||
'pay_type' => 3,
|
||||
];
|
||||
|
||||
$res = $this->model->dataUpdate(['id'=>$input['id']],$update);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 09:52
|
||||
* @功能说明:核销订单
|
||||
*/
|
||||
public function hxOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order = $this->model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if(empty($order)){
|
||||
|
||||
$this->errorMsg('订单未找到');
|
||||
}
|
||||
//自提
|
||||
if($order['send_type']==1&&$order['pay_type']!=2){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
}
|
||||
//快递
|
||||
if($order['send_type']==2&&$order['pay_type']!=3){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
}
|
||||
|
||||
$refund_model = new RefundOrder();
|
||||
//判断有无申请中的退款订单
|
||||
$refund_order = $refund_model->dataInfo(['order_id'=>$order['id'],'status'=>1]);
|
||||
|
||||
if(!empty($refund_order)){
|
||||
|
||||
$this->errorMsg('该订单正在申请退款,请先处理再核销');
|
||||
|
||||
}
|
||||
|
||||
$res = $this->model->hxOrder($order);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:58
|
||||
* @功能说明:订单详情
|
||||
*/
|
||||
public function orderInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 17:50
|
||||
* @功能说明:退款订单详情
|
||||
*/
|
||||
public function refundOrderInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->refund_order_model->dataInfo($dis);
|
||||
|
||||
$data['pay_order_code'] = $this->model->where(['id'=>$data['order_id']])->value('order_code');
|
||||
|
||||
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
|
||||
|
||||
$data['refund_time'] = date('Y-m-d H:i:s',$data['refund_time']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-17 17:44
|
||||
* @功能说明:退款订单列表
|
||||
*/
|
||||
public function refundOrderList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
//商品名字搜索
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
}
|
||||
//订单状态搜索
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis[] = ['a.status','=',$input['status']];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.status','>',-1];
|
||||
|
||||
}
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['order_code'])){
|
||||
|
||||
$where[] = ['a.order_code','like','%'.$input['order_code'].'%'];
|
||||
|
||||
$where[] = ['d.order_code','like','%'.$input['order_code'].'%'];
|
||||
}
|
||||
$data = $this->refund_order_model->adminDataList($dis,$input['limit'],$where);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 09:21
|
||||
* @功能说明:拒绝退款
|
||||
*/
|
||||
public function noPassRefund(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$res = $this->refund_order_model->noPassRefund($input['id']);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**\
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 09:28
|
||||
* @功能说明:同意退款
|
||||
*/
|
||||
public function passRefund(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$res = $this->refund_order_model->passOrder($input['id'],$input['price'],$this->payConfig(),0,$input['text']);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 13:37
|
||||
* @功能说明:数据统计
|
||||
*/
|
||||
public function dateCount(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$cap_id = $input['cap_id'];
|
||||
|
||||
$date_model = new Date();
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$cap_model = new Cap();
|
||||
|
||||
$date_model->dataInit($this->_uniacid);
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
//时间搜素
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['date_str','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
$date_list = $date_model->dataList($dis,$input['limit']);
|
||||
//店铺名字
|
||||
$date_list['store_name'] = $cap_model->where(['id'=>$cap_id])->value('store_name');
|
||||
//开始时间结束时间
|
||||
if(!empty($start_time)){
|
||||
|
||||
$date_list['start_time'] = $start_time;
|
||||
|
||||
$date_list['end_time'] = $end_time;
|
||||
|
||||
}else{
|
||||
|
||||
$date_list['start_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->min('date_str');
|
||||
|
||||
$date_list['end_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->max('date_str');
|
||||
|
||||
}
|
||||
|
||||
if(!empty($date_list['data'])){
|
||||
|
||||
foreach ($date_list['data'] as &$v){
|
||||
//订单金额
|
||||
$v['order_price'] = $this->model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
//退款金额
|
||||
$v['refund_price'] = $this->refund_order_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
//提现金额
|
||||
$v['wallet_price'] = $wallet_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($date_list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
406
app/shop/controller/AdminSetting.php
Normal file
406
app/shop/controller/AdminSetting.php
Normal file
@@ -0,0 +1,406 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\MsgConfig;
|
||||
use app\shop\model\PayConfig;
|
||||
use think\App;
|
||||
use app\shop\model\Config as Model;
|
||||
|
||||
|
||||
class AdminSetting extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 15:04
|
||||
* @功能说明:配置详情
|
||||
*/
|
||||
public function configInfo(){
|
||||
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:14
|
||||
* @功能说明:编辑配置
|
||||
*/
|
||||
public function configUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = $this->model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:15
|
||||
* @功能说明:banner列表
|
||||
*/
|
||||
public function bannerList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
$banner_model = new Banner();
|
||||
|
||||
$data = $banner_model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:18
|
||||
* @功能说明:添加banner
|
||||
*/
|
||||
public function bannerAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$banner_model = new Banner();
|
||||
|
||||
$res = $banner_model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:20
|
||||
* @功能说明:编辑banner
|
||||
*/
|
||||
public function bannerUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$banner_model = new Banner();
|
||||
|
||||
$res = $banner_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 13:27
|
||||
* @功能说明:banner详情
|
||||
*/
|
||||
public function bannerInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$banner_model = new Banner();
|
||||
|
||||
$res = $banner_model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:27
|
||||
* @功能说明:新闻列表
|
||||
*/
|
||||
public function articleList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$article_model = new Article();
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
}
|
||||
|
||||
$data = $article_model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:37
|
||||
* @功能说明:添加文章
|
||||
*
|
||||
*/
|
||||
public function articleAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$article_model = new Article();
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $article_model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 13:35
|
||||
* @功能说明:编辑文章
|
||||
*/
|
||||
public function articleUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$article_model = new Article();
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$res = $article_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 13:35
|
||||
* @功能说明:文章详情
|
||||
*/
|
||||
public function articleInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$article_model = new Article();
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$res = $article_model->dataInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 13:50
|
||||
* @功能说明:文章下拉框
|
||||
*/
|
||||
public function articleSelect(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$article_model = new Article();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$res = $article_model->where($dis)->field('id,title')->select()->toArray();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 10:53
|
||||
* @功能说明:支付配置详情
|
||||
*/
|
||||
public function payConfigInfo(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$pay_model = new PayConfig();
|
||||
|
||||
$data = $pay_model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 10:55
|
||||
* @功能说明:编辑支付配置
|
||||
*/
|
||||
public function payConfigUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
if(!strstr($input['cert_path'],FILE_UPLOAD_PATH)){
|
||||
|
||||
$input['cert_path'] = FILE_UPLOAD_PATH.$input['cert_path'];
|
||||
|
||||
}
|
||||
if(!strstr($input['key_path'],FILE_UPLOAD_PATH)){
|
||||
|
||||
$input['key_path'] = FILE_UPLOAD_PATH.$input['key_path'];
|
||||
}
|
||||
|
||||
$pay_model = new PayConfig();
|
||||
|
||||
$data = $pay_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-31 15:16
|
||||
* @功能说明:修改密码
|
||||
*/
|
||||
public function updatePass(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$admin = new \app\shop\model\Admin();
|
||||
|
||||
$update = [
|
||||
|
||||
'passwd' => checkPass($input['pass']),
|
||||
];
|
||||
|
||||
$res = $admin->dataUpdate(['uniacid'=>$this->_uniacid],$update);
|
||||
|
||||
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 15:04
|
||||
* @功能说明:配置详情
|
||||
*/
|
||||
public function msgConfigInfo(){
|
||||
|
||||
$msg_model = new MsgConfig();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = $msg_model->dataInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-12 16:14
|
||||
* @功能说明:编辑配置
|
||||
*/
|
||||
public function msgConfigUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$msg_model = new MsgConfig();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = $msg_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
91
app/shop/controller/AdminUser.php
Normal file
91
app/shop/controller/AdminUser.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Date;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\Wallet;
|
||||
use think\App;
|
||||
use app\shop\model\User as Model;
|
||||
|
||||
|
||||
class AdminUser extends AdminRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $order_goods_model;
|
||||
|
||||
protected $refund_order_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Model();
|
||||
|
||||
$this->order_goods_model = new OrderGoods();
|
||||
|
||||
$this->refund_order_model = new RefundOrder();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-24 10:24
|
||||
* @功能说明:用户列表
|
||||
*/
|
||||
public function userList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
//是否授权
|
||||
if(!empty($input['type'])){
|
||||
|
||||
if($input['type']==1){
|
||||
|
||||
$dis[] = ['nickName','=',''];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['nickName','<>',''];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['nickName'])){
|
||||
|
||||
$dis[] = ['nickName','like','%'.$input['nickName'].'%'];
|
||||
}
|
||||
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
|
||||
$data = $this->model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
110
app/shop/controller/Index.php
Normal file
110
app/shop/controller/Index.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\ApiRest;
|
||||
|
||||
use app\Rest;
|
||||
|
||||
use app\shop\model\Article;
|
||||
use app\shop\model\Banner;
|
||||
use app\shop\model\Cap;
|
||||
use app\shop\model\Car;
|
||||
use app\shop\model\Config;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\GoodsCate;
|
||||
use app\shop\model\User;
|
||||
use think\App;
|
||||
|
||||
use think\Request;
|
||||
|
||||
|
||||
|
||||
class Index extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $article_model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Banner();
|
||||
|
||||
$this->article_model = new Article();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 09:20
|
||||
* @功能说明:首页
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$data['article'] = $this->article_model->where($dis)->field('id,title')->order('top desc,id desc')->select()->toArray();
|
||||
|
||||
$data['banner'] = $this->model->where($dis)->field('id,img,link')->order('top desc,id desc')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 09:55
|
||||
* @功能说明:文章详情
|
||||
*/
|
||||
public function articleInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->article_model->dataInfo($dis);
|
||||
|
||||
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 14:16
|
||||
* @功能说明:获取配置信息
|
||||
*/
|
||||
public function configInfo(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->dataInfo($dis);
|
||||
|
||||
return $this->success($config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
938
app/shop/controller/IndexCap.php
Normal file
938
app/shop/controller/IndexCap.php
Normal file
@@ -0,0 +1,938 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\ApiRest;
|
||||
|
||||
use app\shop\model\Cap;
|
||||
use app\shop\model\Config;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\GoodsCate;
|
||||
use app\shop\model\GoodsSh;
|
||||
use app\shop\model\Order;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\RefundOrderGoods;
|
||||
use app\shop\model\User;
|
||||
use app\shop\model\Wallet;
|
||||
use longbingcore\wxcore\WxSetting;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
|
||||
|
||||
class IndexCap extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $cap_info;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Cap();
|
||||
|
||||
$cap_dis[] = ['user_id','=',$this->getUserId()];
|
||||
|
||||
$cap_dis[] = ['status','in',[2,3]];
|
||||
|
||||
$this->cap_info = $this->model->dataInfo($cap_dis);
|
||||
|
||||
if(empty($this->cap_info)){
|
||||
|
||||
$this->errorMsg('你还不是楼长');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 09:59
|
||||
* @功能说明:修改团长信息
|
||||
*/
|
||||
public function capUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $this->cap_info['id']
|
||||
];
|
||||
|
||||
$res = $this->model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 15:48
|
||||
* @功能说明:个人中心
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
$data = $this->getUserInfo();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 09:34
|
||||
* @功能说明:商品分类列表
|
||||
*/
|
||||
public function goodsCateList(){
|
||||
|
||||
$cate_model = new GoodsCate();
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
$dis[] = ['cap_id','=',$this->cap_info['id']];
|
||||
|
||||
$data = $cate_model->dataList($dis,20);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:03
|
||||
* @功能说明:添加商品分类
|
||||
*/
|
||||
public function goodsCateAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$input['cap_id'] = $this->cap_info['id'];
|
||||
|
||||
$cate_model = new GoodsCate();
|
||||
|
||||
$res = $cate_model->dataAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:06
|
||||
* @功能说明:编辑商品分类
|
||||
*/
|
||||
public function goodsCateUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$cate_model = new GoodsCate();
|
||||
|
||||
$cate_info = $cate_model->dataInfo($dis);
|
||||
|
||||
if(empty($cate_info)){
|
||||
|
||||
$this->errorMsg('商品分类不存在');
|
||||
}
|
||||
//如果是删除
|
||||
if(!empty($input['status'])&&$input['status']==-1&&$cate_info['goods_num']>0){
|
||||
|
||||
$this->errorMsg('该分类下存在商品,无法删除');
|
||||
|
||||
}
|
||||
|
||||
$res = $cate_model->dataUpdate($dis,$input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:08
|
||||
* @功能说明:商品分类下拉框
|
||||
*/
|
||||
public function goodsCateSelect(){
|
||||
|
||||
$cate_model = new GoodsCate();
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['cap_id','=',$this->cap_info['id']];
|
||||
|
||||
$data = $cate_model->where($dis)->where('top desc,id desc')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 15:06
|
||||
* @功能说明:商品各个状态下的数量
|
||||
*/
|
||||
public function goodsCount(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'cap_id' => $this->cap_info['id'],
|
||||
|
||||
'status' => 1
|
||||
|
||||
];
|
||||
|
||||
$goods_model = new Goods();
|
||||
//上架数量
|
||||
$data['on_count'] = $goods_model->where($dis)->count();
|
||||
|
||||
$dis['status'] = 2;
|
||||
//下架数量
|
||||
$data['off_count'] = $goods_model->where($dis)->count();
|
||||
|
||||
$dis['status'] = 3;
|
||||
//仓库数量
|
||||
$data['house_count'] = $goods_model->where($dis)->count();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 11:08
|
||||
* @功能说明:商品列表
|
||||
*/
|
||||
public function goodsList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['cap_id','=',$this->cap_info['id']];
|
||||
|
||||
$dis[] = ['status','=',$input['status']];
|
||||
//商品名字搜索
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['goods_name','like','%'.$input['goods_name'].'%'];
|
||||
}
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$data = $goods_model->dataList($dis,10);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
//创建时间
|
||||
$v['create_time'] = date('Y/m/d',strtotime($v['create_time']));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 09:32
|
||||
* @功能说明:添加商品
|
||||
*/
|
||||
public function goodsAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
//0放入仓库 1提交审核
|
||||
$type = !empty($input['type'])?$input['type']:0;
|
||||
|
||||
unset($input['type']);
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$input['cap_id'] = $this->cap_info['id'];
|
||||
|
||||
$input['imgs'] = !empty($input['imgs'])?implode(',',$input['imgs']):'';
|
||||
|
||||
$core = new WxSetting($this->_uniacid);
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$rest = $core->wxContentRlue($input['goods_name']);
|
||||
|
||||
if($rest['errcode'] != 0){
|
||||
|
||||
return $this->error('标题含有违法违规内容');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['text'])){
|
||||
|
||||
$rest = $core->wxContentRlue($input['text']);
|
||||
|
||||
if($rest['errcode'] != 0){
|
||||
|
||||
return $this->error('标题含有违法违规内容');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
//判断是不是需要审核
|
||||
if($config['goods_sh']==1){
|
||||
//待审核
|
||||
$input['status'] = 3;
|
||||
|
||||
}else{
|
||||
//直接上架
|
||||
$input['status'] = 1;
|
||||
|
||||
}
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$id = $goods_model->dataAdd($input);
|
||||
//提交审核
|
||||
if($type==1&&$config['goods_sh']==1){
|
||||
|
||||
$this->subGoodsShAction([$id]);
|
||||
|
||||
}
|
||||
|
||||
return $this->success(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:28
|
||||
* @功能说明:编辑商品信息
|
||||
*/
|
||||
public function goodsUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$type = !empty($input['type'])?$input['type']:0;
|
||||
|
||||
unset($input['type']);
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$input['imgs'] = !empty($input['imgs'])?implode(',',$input['imgs']):'';
|
||||
|
||||
$core = new WxSetting($this->_uniacid);
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$rest = $core->wxContentRlue($input['goods_name']);
|
||||
|
||||
if($rest['errcode'] != 0){
|
||||
|
||||
return $this->error('标题含有违法违规内容');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['text'])){
|
||||
|
||||
$rest = $core->wxContentRlue($input['text']);
|
||||
|
||||
if($rest['errcode'] != 0){
|
||||
|
||||
return $this->error('标题含有违法违规内容');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
//判断是不是需要审核
|
||||
if($config['goods_sh']==1){
|
||||
|
||||
$input['status'] = 3;
|
||||
}
|
||||
|
||||
$res = $goods_model->goodsUpdate($dis,$input);
|
||||
//提交审核
|
||||
if($type==1&&$config['goods_sh']==1){
|
||||
|
||||
$this->subGoodsShAction([$input['id']]);
|
||||
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 14:18
|
||||
* @功能说明:商品上下架
|
||||
*/
|
||||
public function goodsStatusUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$res = $goods_model->dataUpdate($dis,['status'=>$input['status']]);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:29
|
||||
* @功能说明:商品详情
|
||||
*/
|
||||
public function goodsInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$res = $goods_model->dataInfo($dis);
|
||||
|
||||
$cate_model = new GoodsCate();
|
||||
//分类名字
|
||||
$res['cate_name'] = $cate_model->where(['id'=>$res['cate_id']])->value('title');
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
* @功能说明:提交审核方法
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 14:27
|
||||
*/
|
||||
public function subGoodsShAction($goods_id){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'cap_id' => $this->cap_info['id'],
|
||||
|
||||
'order_code' => orderCode(),
|
||||
|
||||
'status' => 1,
|
||||
|
||||
];
|
||||
|
||||
$goods_sh_model = new GoodsSh();
|
||||
|
||||
$goods_sh_model->dataAdd($insert);
|
||||
|
||||
$id = $goods_sh_model->getLastInsID();
|
||||
//提交审核
|
||||
$res = $goods_sh_model->subSh($id,$goods_id);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 10:30
|
||||
* @功能说明:提交商品审核
|
||||
*/
|
||||
public function subGoodsSh(){
|
||||
|
||||
$input = $this->_input;
|
||||
//全选
|
||||
if(!empty($input['all'])){
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'cap_id' => $this->cap_info['id'],
|
||||
|
||||
'status' => 3
|
||||
];
|
||||
|
||||
$goods_id = $goods_model->where($dis)->column('id');
|
||||
|
||||
}else{
|
||||
|
||||
$goods_id = $input['goods_id'];
|
||||
}
|
||||
|
||||
if(empty($goods_id)){
|
||||
|
||||
$this->errorMsg('暂无商品');
|
||||
}
|
||||
//提交审核
|
||||
$res = $this->subGoodsShAction($goods_id);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 11:13
|
||||
* @功能说明:商品审核列表
|
||||
*/
|
||||
public function shList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['cap_id','=',$this->cap_info['id']];
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis[] = ['status','=',$input['status']];
|
||||
}
|
||||
|
||||
$goods_sh_model = new GoodsSh();
|
||||
|
||||
$data = $goods_sh_model->dataList($dis);
|
||||
|
||||
$data['sh_ing'] = $goods_sh_model->shIng($this->cap_info['id']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 11:21
|
||||
* @功能说明:审核详情
|
||||
*/
|
||||
public function shInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$goods_sh_model = new GoodsSh();
|
||||
|
||||
$data = $goods_sh_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 15:48
|
||||
* @功能说明:个人中心
|
||||
*/
|
||||
public function orderList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.cap_id','=',$this->cap_info['id']];
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.goods_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['a.order_code','like','%'.$input['name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['pay_type'])){
|
||||
|
||||
$dis[] = ['a.pay_type','=',$input['pay_type']];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.pay_type','>',1];
|
||||
|
||||
}
|
||||
|
||||
$order_model = new Order();
|
||||
|
||||
$data = $order_model->indexDataList($dis,$where);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 11:31
|
||||
* @功能说明:商品批量上下架
|
||||
*/
|
||||
public function someGoodsUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$goods_model = new Goods();
|
||||
//全选
|
||||
if(!empty($input['all'])){
|
||||
|
||||
$res = $goods_model->where('cap_id','=',$this->cap_info['id'])->where(['status'=>$input['type']])->update(['status'=>$input['status']]);
|
||||
|
||||
}else{
|
||||
|
||||
$res = $goods_model->where('id','in',$input['goods_id'])->update(['status'=>$input['status']]);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 17:29
|
||||
* @功能说明:退款订单详情
|
||||
*
|
||||
*/
|
||||
public function refundOrderList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.cap_id','=',$this->cap_info['id']];
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.goods_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['a.order_code','like','%'.$input['name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis[] = ['a.status','=',$input['status']];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.status','>',-1];
|
||||
|
||||
}
|
||||
|
||||
$refund_model = new RefundOrder();
|
||||
|
||||
$data = $refund_model->indexDataList($dis,$where);
|
||||
|
||||
$data['refund_ing'] = $refund_model->refundIng($this->cap_info['id']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 11:34
|
||||
* @功能说明:同意退款
|
||||
*/
|
||||
public function passRefund(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$refund_model = new RefundOrder();
|
||||
//同意退款
|
||||
$res = $refund_model->passOrder($input['id'],$input['price'],$this->payConfig(),$this->getUserId());
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 09:21
|
||||
* @功能说明:拒绝退款
|
||||
*/
|
||||
public function noPassRefund(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$refund_order_model = new RefundOrder();
|
||||
|
||||
$res = $refund_order_model->noPassRefund($input['id']);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-24 13:33
|
||||
* @功能说明:团长审核提现
|
||||
*/
|
||||
public function applyWallet(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
if($input['apply_cash']>$this->cap_info['cap_cash']){
|
||||
|
||||
$this->errorMsg('余额不足');
|
||||
}
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
$key = 'cap_wallet'.$this->getUserId();
|
||||
|
||||
$value = getCache($key);
|
||||
|
||||
if(!empty($value)){
|
||||
|
||||
$this->errorMsg('网络错误,请刷新重试');
|
||||
|
||||
}
|
||||
//加一个锁防止重复提交
|
||||
incCache($key,1,$this->_uniacid);
|
||||
|
||||
Db::startTrans();
|
||||
//减佣金
|
||||
$res = $this->model->dataUpdate(['id'=>$this->cap_info['id']],['cap_cash'=>$this->cap_info['cap_cash']-$input['apply_cash']]);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
//减掉
|
||||
delCache($key,$this->_uniacid);
|
||||
|
||||
$this->errorMsg('申请失败');
|
||||
}
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'cap_id' => $this->cap_info['id'],
|
||||
|
||||
'apply_cash' => $input['apply_cash'],
|
||||
|
||||
'order_code' => orderCode(),
|
||||
|
||||
'text' => $input['text'],
|
||||
|
||||
'true_cash' => round($input['apply_cash']*$config['cash_balance']/100,2),
|
||||
|
||||
'cash_balance' => $config['cash_balance']
|
||||
|
||||
];
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
//提交审核
|
||||
$res = $wallet_model->dataAdd($insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
//减掉
|
||||
delCache($key,$this->_uniacid);
|
||||
|
||||
$this->errorMsg('申请失败');
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
//减掉
|
||||
delCache($key,$this->_uniacid);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-25 17:14
|
||||
* @功能说明:楼长核销订单
|
||||
*/
|
||||
public function hxOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order_model= new Order();
|
||||
|
||||
$order = $order_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if(empty($order)){
|
||||
|
||||
$this->errorMsg('订单未找到');
|
||||
}
|
||||
|
||||
if($order['pay_type']!=2){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
}
|
||||
|
||||
if($order['cap_id']!=$this->cap_info['id']){
|
||||
|
||||
$this->errorMsg('你不是该订单的楼长');
|
||||
|
||||
}
|
||||
|
||||
$refund_model = new RefundOrder();
|
||||
//判断有无申请中的退款订单
|
||||
$refund_order = $refund_model->dataInfo(['order_id'=>$order['id'],'status'=>1]);
|
||||
|
||||
if(!empty($refund_order)){
|
||||
|
||||
$this->errorMsg('该订单正在申请退款,请先处理再核销');
|
||||
|
||||
}
|
||||
|
||||
$res = $order_model->hxOrder($input['id'],$this->cap_info['id']);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-30 13:38
|
||||
* @功能说明:团长端佣金信息
|
||||
*/
|
||||
public function capCashInfo(){
|
||||
|
||||
$key = 'cap_wallet'.$this->getUserId();
|
||||
//减掉
|
||||
delCache($key,$this->_uniacid);
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
//可提现佣金
|
||||
$data['cap_cash'] = $this->cap_info['cap_cash'];
|
||||
//累计提现
|
||||
$data['cap_total_price'] = $wallet_model->capCash($this->cap_info['id']);
|
||||
//累计收益
|
||||
$data['cap_frozen_price'] = $wallet_model->capCash($this->cap_info['id'],1);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-30 14:39
|
||||
* @功能说明:团长提现记录
|
||||
*/
|
||||
public function capCashList(){
|
||||
|
||||
$wallet_model = new Wallet();
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'cap_id' => $this->cap_info['id']
|
||||
];
|
||||
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis['status'] = $input['status'];
|
||||
}
|
||||
//提现记录
|
||||
$data = $wallet_model->dataList($dis,10);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
389
app/shop/controller/IndexGoods.php
Normal file
389
app/shop/controller/IndexGoods.php
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\ApiRest;
|
||||
|
||||
use app\farm\model\ShopGoods;
|
||||
use app\massage\model\Coupon;
|
||||
use app\massage\model\CouponRecord;
|
||||
use app\Rest;
|
||||
|
||||
use app\shop\model\Cap;
|
||||
use app\shop\model\Car;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\GoodsCate;
|
||||
use app\shop\model\GoodsSpe;
|
||||
use app\shop\model\GoodsSpePrice;
|
||||
use app\shop\model\Integral;
|
||||
use app\shop\model\LuckConfig;
|
||||
use app\shop\model\LuckDraw;
|
||||
use app\shop\model\LuckRecord;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\SeckillConfig;
|
||||
use app\shop\model\SeckillGoods;
|
||||
use app\shop\model\SeckillInfo;
|
||||
use app\shop\model\SeckillList;
|
||||
use app\shop\model\User;
|
||||
use think\App;
|
||||
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
|
||||
|
||||
|
||||
class IndexGoods extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $cate_model;
|
||||
|
||||
protected $kill_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new ShopGoods();
|
||||
|
||||
$this->kill_model = new SeckillList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 16:33
|
||||
* @功能说明:秒杀活动
|
||||
*/
|
||||
public function killAtvList(){
|
||||
|
||||
$this->kill_model->initAtv();
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['end_time','>',time()];
|
||||
|
||||
$data = $this->kill_model->where($dis)->order('start_time,id desc')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 11:38
|
||||
* @功能说明:热门商品列表
|
||||
*/
|
||||
public function hotGoodsList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['index_show','=',1];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['goods_name','like','%'.$input['goods_name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
$data = $goods_model->where($dis)->order('top desc,id desc')->paginate(10)->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 15:51
|
||||
* @功能说明:秒杀商品列表
|
||||
*/
|
||||
public function killGoodsList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$goods_model = new SeckillGoods();
|
||||
|
||||
$dis[] = ['a.atv_id','=',$input['atv_id']];
|
||||
|
||||
$dis[] = ['b.status','=',1];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
$dis[] = ['e.status','=',1];
|
||||
|
||||
$dis[] = ['d.status','=',2];
|
||||
|
||||
$dis[] = ['d.business_status','=',1];
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['b.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
$data = $goods_model->goodsList($dis);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$info_model = new SeckillInfo();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'goods_id' => $v['goods_id'],
|
||||
|
||||
'kill_id' => $v['atv_id'],
|
||||
|
||||
'user_id' => $this->getUserId()
|
||||
];
|
||||
|
||||
$find = $info_model->dataInfo($dis);
|
||||
|
||||
$v['have_notice'] = !empty($find)?1:0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-24 15:10
|
||||
* @功能说明:秒杀活动提醒
|
||||
*/
|
||||
public function killNotice(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'goods_id' => $input['goods_id'],
|
||||
|
||||
'kill_id' => $input['atv_id'],
|
||||
|
||||
'user_id' => $this->getUserId()
|
||||
|
||||
];
|
||||
|
||||
$info_model = new SeckillInfo();
|
||||
|
||||
$find = $info_model->dataInfo($dis);
|
||||
|
||||
if(empty($find)){
|
||||
|
||||
$info_model->dataAdd($dis);
|
||||
|
||||
}else{
|
||||
|
||||
$info_model->where($dis)->delete();
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 14:03
|
||||
* @功能说明:抽奖详情
|
||||
*/
|
||||
public function luckInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['start_time','<',time()];
|
||||
|
||||
$dis[] = ['end_time','>',time()];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
$atv= $luck_model->dataInfo($dis);
|
||||
|
||||
if(empty($atv)){
|
||||
|
||||
return $this->success($atv);
|
||||
$this->errorMsg('活动已经结束');
|
||||
}
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$record_model = new LuckRecord();
|
||||
|
||||
$user_model = new \app\farm\model\User();
|
||||
|
||||
$list = $config_model->where(['luck_id'=>$atv['id']])->order('top,id desc')->select()->toArray();
|
||||
|
||||
$user_num = $record_model->where(['user_id'=>$this->getUserId(),'atv_id'=>$atv['id']])->whereTime('create_time','today')->count();
|
||||
|
||||
$arr['data'] = $list;
|
||||
|
||||
$arr['user_num'] = ($atv['day_times'] - $user_num)>0?$atv['day_times'] - $user_num:0;
|
||||
|
||||
$arr['integral'] = $atv['integral'];
|
||||
|
||||
$arr['atv_id'] = $atv['id'];
|
||||
|
||||
$arr['cover'] = $atv['cover'];
|
||||
|
||||
$arr['text'] = $atv['text'];
|
||||
|
||||
$arr['day_times']= $atv['day_times'];
|
||||
|
||||
$arr['user_integral'] = $user_model->where(['id'=>$this->getUserId()])->sum('integral');
|
||||
|
||||
return $this->success($arr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 16:12
|
||||
* @功能说明:中奖记录
|
||||
*/
|
||||
public function luckRecord(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$record_model = new LuckRecord();
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.atv_id' => $input['id'],
|
||||
|
||||
'a.is_luck'=> 1
|
||||
];
|
||||
|
||||
$data = $record_model->recordList($dis);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-25 11:04
|
||||
* @功能说明:用户中奖记录
|
||||
*/
|
||||
public function userLuckRecord(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$record_model = new LuckRecord();
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.user_id' => $this->getUserId(),
|
||||
|
||||
// 'a.is_luck'=> 1
|
||||
];
|
||||
|
||||
if(!empty($input['id'])){
|
||||
|
||||
$dis['a.atv_id'] = $input['id'];
|
||||
}
|
||||
|
||||
$data = $record_model->recordList($dis);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 14:09
|
||||
* @功能说明:用户抽奖
|
||||
*/
|
||||
public function luckDraw(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$luck_model = new LuckDraw();
|
||||
|
||||
$record_model = new LuckRecord();
|
||||
|
||||
$dis[] = ['id','=',$input['id']];
|
||||
|
||||
$dis[] = ['start_time','<',time()];
|
||||
|
||||
$dis[] = ['end_time','>',time()];
|
||||
|
||||
$data = $luck_model->dataInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('活动未在规则时间内');
|
||||
}
|
||||
|
||||
$user_num = $record_model->where(['user_id'=>$this->getUserId(),'atv_id'=>$input['id']])->whereTime('create_time','today')->count();
|
||||
|
||||
if($user_num>=$data['day_times']){
|
||||
|
||||
$this->errorMsg('超过每日抽奖次数,你今日已抽'.$user_num.'次');
|
||||
}
|
||||
|
||||
$user_model = new \app\farm\model\User();
|
||||
|
||||
$user_integral= $user_model->where(['id'=>$this->getUserId()])->sum('integral');
|
||||
|
||||
if($data['integral']>$user_integral){
|
||||
|
||||
$this->errorMsg('积分不足');
|
||||
}
|
||||
//抽奖
|
||||
$res = $luck_model->luckDraw($input['id'],$this->getUserId(),$data['integral'],$user_num);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
819
app/shop/controller/IndexOrder.php
Normal file
819
app/shop/controller/IndexOrder.php
Normal file
@@ -0,0 +1,819 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\ApiRest;
|
||||
|
||||
use app\massage\model\Coupon;
|
||||
use app\massage\model\CouponRecord;
|
||||
use app\shop\model\Address;
|
||||
use app\shop\model\Car;
|
||||
use app\shop\model\Config;
|
||||
use app\shop\model\Goods;
|
||||
use app\shop\model\MsgConfig;
|
||||
use app\shop\model\Order;
|
||||
use app\shop\model\OrderAddress;
|
||||
use app\shop\model\OrderGoods;
|
||||
use app\shop\model\RefundOrder;
|
||||
use app\shop\model\User;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use think\Request;
|
||||
|
||||
|
||||
class IndexOrder extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $refund_model;
|
||||
|
||||
protected $order_goods_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new Order();
|
||||
|
||||
$this->refund_model = new RefundOrder();
|
||||
|
||||
$this->order_goods_model = new OrderGoods();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 15:48
|
||||
* @功能说明:个人中心
|
||||
*/
|
||||
public function orderList(){
|
||||
//超时自动取消订单
|
||||
$this->model->autoCancelOrder($this->_uniacid,$this->getUserId());
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.user_id','=',$this->getUserId()];
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.goods_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['a.order_code','like','%'.$input['name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['pay_type'])){
|
||||
|
||||
$dis[] = ['a.pay_type','=',$input['pay_type']];
|
||||
|
||||
}
|
||||
|
||||
$data = $this->model->indexDataList($dis,$where);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$can_refund_num = is_array($v['order_goods'])?array_sum(array_column($v['order_goods'],'can_refund_num')):0;
|
||||
|
||||
if(!empty($v['add_price'])&&$v['add_price_refund']==0){
|
||||
|
||||
$can_refund_num+=1;
|
||||
}
|
||||
//是否可以申请退款
|
||||
if(($v['pay_type']==7&&$v['can_refund_time']>time()&&$can_refund_num>0)||($v['pay_type']==2&&$can_refund_num>0)){
|
||||
|
||||
$v['can_refund'] = 1;
|
||||
|
||||
}else{
|
||||
|
||||
$v['can_refund'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:58
|
||||
* @功能说明:订单详情
|
||||
*/
|
||||
public function orderInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->dataInfo($dis);
|
||||
|
||||
$data['over_time'] -= time();
|
||||
|
||||
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
|
||||
//剩余可申请退款数量
|
||||
$can_refund_num = array_sum(array_column($data['order_goods'],'can_refund_num'));
|
||||
//如果有跑腿业务 可退款数量+1
|
||||
if(!empty($data['add_price'])&&$data['add_price_refund']==0){
|
||||
|
||||
$can_refund_num+=1;
|
||||
}
|
||||
//是否可以申请退款
|
||||
if(($data['pay_type']==7&&$data['can_refund_time']>time()&&$can_refund_num>0)||($data['pay_type']==2&&$can_refund_num>0)){
|
||||
|
||||
$data['can_refund'] = 1;
|
||||
|
||||
}else{
|
||||
|
||||
$data['can_refund'] = 0;
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 17:29
|
||||
* @功能说明:退款订单详情
|
||||
*
|
||||
*/
|
||||
public function refundOrderList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.user_id','=',$this->getUserId()];
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.goods_name','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['a.order_code','like','%'.$input['name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$dis[] = ['a.status','=',$input['status']];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.status','>',-1];
|
||||
|
||||
}
|
||||
|
||||
$data = $this->refund_model->indexDataList($dis,$where);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 17:50
|
||||
* @功能说明:退款订单详情
|
||||
*/
|
||||
|
||||
public function refundOrderInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->refund_model->dataInfo($dis);
|
||||
|
||||
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
|
||||
|
||||
$data['refund_time'] = date('Y-m-d H:i:s',$data['refund_time']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-09-01 16:08
|
||||
* @功能说明:配送方式
|
||||
*/
|
||||
public function goodsSendType(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$car_model = new Car();
|
||||
|
||||
$is_show = isset($input['is_show'])?$input['is_show']:1;
|
||||
|
||||
$list = $car_model->carList($this->getUserId(),1,0,$is_show);
|
||||
|
||||
$data['is_self'] = 0;
|
||||
|
||||
$data['is_send'] = 0;
|
||||
|
||||
if(!empty($list)){
|
||||
|
||||
foreach ($list as &$value){
|
||||
|
||||
$data['is_self'] = !empty($value['is_self'])?$value['is_self']:$data['is_self'];
|
||||
|
||||
$data['is_send'] = !empty($value['is_send'])?$value['is_send']:$data['is_send'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-22 09:43
|
||||
* @功能说明:下单页面详情
|
||||
*/
|
||||
public function payOrderInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$send_type = !empty($input['send_type'])?$input['send_type']:0;
|
||||
|
||||
$is_show = isset($input['is_show'])?$input['is_show']:1;
|
||||
|
||||
$no_i = isset($input['no_i'])?$input['no_i']:1;
|
||||
|
||||
$coupon_id = isset($input['coupon_id'])?$input['coupon_id']:0;
|
||||
|
||||
$order_info = $this->model->payOrderInfo($this->getUserId(),$is_show,$no_i,$send_type,$coupon_id);
|
||||
|
||||
$address_model = new Address();
|
||||
|
||||
if(!empty($input['address_id'])){
|
||||
//默认地址
|
||||
$order_info['address_info'] = $address_model->dataInfo(['id'=>$input['address_id']]);
|
||||
|
||||
}
|
||||
//自提地址
|
||||
if($send_type==1){
|
||||
|
||||
$config_model = new \app\massage\model\Config();
|
||||
|
||||
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
$order_info['address_info'] = [
|
||||
|
||||
'mobile' => $config['mobile'],
|
||||
|
||||
'lat' => $config['zt_lat'],
|
||||
|
||||
'lng' => $config['zt_lng'],
|
||||
|
||||
'address' => $config['zt_address'],
|
||||
|
||||
'address_id' => 0,
|
||||
|
||||
'user_name' => $config['app_name'],
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$coupon_modle = new Coupon();
|
||||
|
||||
$coupon_record_model = new CouponRecord();
|
||||
//可用优惠券数量
|
||||
$canUseCoupon = $coupon_modle->canUseCoupon($this->getUserId(),2,$is_show,$no_i);
|
||||
|
||||
$order_info['canUseCoupon'] = $coupon_record_model->where('id','in',$canUseCoupon)->sum('num');
|
||||
|
||||
return $this->success($order_info);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-22 09:53
|
||||
* @功能说明:下单
|
||||
*/
|
||||
public function payOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$send_type = isset($input['send_type'])?$input['send_type']:1;
|
||||
|
||||
$is_show = isset($input['is_show'])?$input['is_show']:1;
|
||||
|
||||
$no_i = isset($input['no_i'])?$input['no_i']:1;
|
||||
|
||||
$coupon_id = !empty($input['coupon_id'])?$input['coupon_id']:0;
|
||||
|
||||
$order_info = $this->model->payOrderInfo($this->getUserId(),$is_show,$no_i,$send_type,$coupon_id);
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$address_order_model = new OrderAddress();
|
||||
|
||||
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
$member_config_model = new \app\member\model\Config();
|
||||
|
||||
$member_config = $member_config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$order_insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'order_code' => orderCode(),
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'pay_price' => $order_info['pay_price'],
|
||||
|
||||
'true_price' => $order_info['pay_price'],
|
||||
|
||||
'pay_type' => 1,
|
||||
|
||||
'goods_price'=> $order_info['goods_price'],
|
||||
|
||||
'true_goods_price'=> $order_info['goods_price'],
|
||||
|
||||
'init_price' => $order_info['init_price'],
|
||||
|
||||
'init_goods_price' => $order_info['init_goods_price'],
|
||||
|
||||
'text' => $input['text'],
|
||||
|
||||
'over_time' => time()+$config['over_time']*60,
|
||||
|
||||
'send_type' => $send_type,
|
||||
|
||||
'integral' => $order_info['integral'],
|
||||
|
||||
'discount' => $order_info['discount'],
|
||||
|
||||
'freight' => $order_info['freight'],
|
||||
//会员折扣抵扣了多少钱
|
||||
'member_discount_price' => $order_info['member_discount_price'],
|
||||
|
||||
'integral_discount_price' => $order_info['integral_discount_price'],
|
||||
|
||||
'balance' => !empty($input['is_balance'])?$order_info['pay_price']:0,
|
||||
//付费获得的积分
|
||||
'get_integral' => empty($input['is_balance'])?floor($order_info['pay_price']*$member_config['integral_cash']):0,
|
||||
|
||||
];
|
||||
|
||||
//下单
|
||||
$res = $this->model->dataAdd($order_insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('下单失败');
|
||||
}
|
||||
|
||||
$order_id = $this->model->getLastInsID();
|
||||
|
||||
if($send_type==2){
|
||||
//添加下单地址
|
||||
$res = $address_order_model->orderAddressAdd($input['address_id'],$order_id);
|
||||
|
||||
}else{
|
||||
|
||||
$res = $address_order_model->selfAddressAdd($this->_uniacid,$order_id,$input['user_name'],$input['mobile']);
|
||||
|
||||
}
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
|
||||
}
|
||||
|
||||
$order_insert['id'] = $order_id;
|
||||
|
||||
//使用优惠券
|
||||
if(!empty($order_info['coupon_id'])){
|
||||
|
||||
$coupon_record_model = new CouponRecord();
|
||||
|
||||
$coupon_id = $coupon_record_model->couponUse($order_info['coupon_id'],$order_id);
|
||||
|
||||
$this->model->dataUpdate(['id'=>$order_id],['coupon_id'=>$coupon_id]);
|
||||
|
||||
}
|
||||
|
||||
if(empty($order_info['order_goods'])){
|
||||
|
||||
$this->errorMsg('订单错误');
|
||||
}
|
||||
//添加到子订单
|
||||
$res = $this->order_goods_model->orderGoodsAdd($order_info['order_goods'],$order_id,$is_show,$this->getUserId());
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
//积分活动
|
||||
$res = $this->model->marketingCheck($order_insert,$order_info['order_goods']);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
//如果是0元
|
||||
if($order_insert['pay_price']<=0){
|
||||
|
||||
$this->model->orderResult($order_insert['order_code'],$order_insert['order_code']);
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
//余额支付
|
||||
if(!empty($input['is_balance'])){
|
||||
|
||||
$user_model = new \app\massage\model\User();
|
||||
|
||||
$user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance');
|
||||
|
||||
if($user_balance<$order_insert['pay_price']){
|
||||
|
||||
$this->errorMsg('余额不足');
|
||||
}
|
||||
|
||||
$this->model->orderResult($order_insert['order_code'],$order_insert['order_code']);
|
||||
|
||||
return $this->success(true);
|
||||
|
||||
}
|
||||
//微信支付
|
||||
$pay_controller = new IndexWxPay($this->app);
|
||||
//支付
|
||||
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"团购",['type' => 'SchoolShop' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']);
|
||||
|
||||
$arr['pay_list']= $jsApiParameters;
|
||||
|
||||
return $this->success($arr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-25 15:59
|
||||
* @功能说明:重新支付
|
||||
*/
|
||||
public function rePayOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order_insert = $this->model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($order_insert['pay_type']!=1){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
|
||||
}
|
||||
//余额支付
|
||||
if(!empty($order_insert['balance'])){
|
||||
|
||||
$user_model = new \app\massage\model\User();
|
||||
|
||||
$user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance');
|
||||
|
||||
if($user_balance<$order_insert['pay_price']){
|
||||
|
||||
$this->errorMsg('余额不足');
|
||||
}
|
||||
|
||||
$this->model->orderResult($order_insert['order_code'],$order_insert['order_code']);
|
||||
|
||||
return $this->success(true);
|
||||
|
||||
}
|
||||
//微信支付
|
||||
$pay_controller = new IndexWxPay($this->app);
|
||||
//支付
|
||||
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"团购",['type' => 'SchoolShop' , 'out_trade_no' => $order_insert['order_code']],$order_insert['pay_price']);
|
||||
|
||||
$arr['pay_list']= $jsApiParameters;
|
||||
|
||||
return $this->success($arr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-25 16:38
|
||||
* @功能说明:取消订单
|
||||
*/
|
||||
|
||||
public function cancelOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order_insert = $this->model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($order_insert['pay_type']!=1){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
|
||||
}
|
||||
|
||||
$res = $this->model->cancelOrder($order_insert);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 11:39
|
||||
* @功能说明:申请退款
|
||||
*/
|
||||
public function applyOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order = $this->model->dataInfo(['id'=>$input['order_id']]);
|
||||
|
||||
if(empty($order)){
|
||||
|
||||
$this->errorMsg('订单未找到');
|
||||
}
|
||||
|
||||
if($order['pay_type']<2&&$order['have_tx']!=0){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
|
||||
}
|
||||
|
||||
if(empty($input['list'])){
|
||||
|
||||
$this->errorMsg('请选择商品');
|
||||
|
||||
}
|
||||
|
||||
if($order['can_refund_time']<time()&&$order['pay_type']==7){
|
||||
|
||||
$this->errorMsg('核销后24小时内才能申请退款哦');
|
||||
|
||||
}
|
||||
//申请退款
|
||||
$res = $this->refund_model->applyRefund($order,$input);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
$this->errorMsg($res['msg']);
|
||||
}
|
||||
// //给楼长发送服务通知
|
||||
// $msg_model = new MsgConfig();
|
||||
//
|
||||
// $refund_order = $this->refund_model->dataInfo(['id'=>$res]);
|
||||
// //发送通知
|
||||
// $msg_model->refundSendMsg($refund_order);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 15:55
|
||||
* @功能说明:取消退款
|
||||
*/
|
||||
public function cancelRefundOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order = $this->refund_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($order['status']!=1){
|
||||
|
||||
$this->errorMsg('订单已经审核');
|
||||
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $this->refund_model->dataUpdate(['id'=>$input['id']],['status'=>-1,'cancel_time'=>time()]);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('取消失败');
|
||||
}
|
||||
|
||||
if(!empty($order['order_goods'])){
|
||||
|
||||
$order_goods_model = new OrderGoods();
|
||||
|
||||
foreach ($order['order_goods'] as $v){
|
||||
|
||||
if(!empty($v['order_goods_id'])){
|
||||
|
||||
$num = $v['goods_num'];
|
||||
|
||||
$res = $order_goods_model->where(['id'=>$v['order_goods_id']])->update(['can_refund_num'=>Db::Raw("can_refund_num+$num")]);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('取消失败');
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$this->model->dataUpdate(['id'=>$order['order_id']],['add_price_refund'=>0]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-07 15:30
|
||||
* @功能说明:刷新订单二维码
|
||||
*/
|
||||
public function refreshQr(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$qr_insert = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
//获取二维码
|
||||
$qr = $this->model->orderQr($qr_insert,$this->_uniacid);
|
||||
|
||||
if(!empty($qr)){
|
||||
|
||||
$this->model->dataUpdate(['id'=>$input['id']],['qr'=>$qr]);
|
||||
|
||||
}
|
||||
|
||||
return $this->success($qr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-25 17:14
|
||||
* @功能说明:楼长核销订单
|
||||
*/
|
||||
public function endOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$order_model= new Order();
|
||||
|
||||
$order = $order_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if(empty($order)){
|
||||
|
||||
$this->errorMsg('订单未找到');
|
||||
}
|
||||
|
||||
if(empty($order)){
|
||||
|
||||
$this->errorMsg('订单未找到');
|
||||
}
|
||||
//自提
|
||||
if($order['send_type']==1&&$order['pay_type']!=2){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
}
|
||||
//快递
|
||||
if($order['send_type']==2&&$order['pay_type']!=3){
|
||||
|
||||
$this->errorMsg('订单状态错误');
|
||||
}
|
||||
|
||||
if($order['send_type']==1){
|
||||
|
||||
$user_model = new \app\massage\model\User();
|
||||
|
||||
$role = $user_model->where(['id'=>$this->getUserId()])->value('role');
|
||||
|
||||
if($role!=1){
|
||||
|
||||
$this->errorMsg('只有管理员才能核销');
|
||||
}
|
||||
}
|
||||
|
||||
$refund_model = new RefundOrder();
|
||||
//判断有无申请中的退款订单
|
||||
$refund_order = $refund_model->dataInfo(['order_id'=>$order['id'],'status'=>1]);
|
||||
|
||||
if(!empty($refund_order)){
|
||||
|
||||
$this->errorMsg('该订单正在申请退款,请先处理再核销');
|
||||
|
||||
}
|
||||
|
||||
$res = $order_model->hxOrder($input['id'],$this->getUserId());
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getPayNumber(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$number= $this->order_goods_model->getGoodsNumber(['a.goods_id'=>$input['id'],'b.user_id'=>$this->getUserId()] );
|
||||
|
||||
return $this->success(['number'=>$number]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-07-10 00:40
|
||||
* @功能说明:可用的优惠券列表
|
||||
*/
|
||||
public function couponList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$coupon_record_model = new CouponRecord();
|
||||
|
||||
$is_show = isset($input['is_show'])?$input['is_show']:1;
|
||||
|
||||
$coupon_id = $coupon_model->canUseCoupon($this->getUserId(),2,$is_show);
|
||||
|
||||
$data = $coupon_record_model->where('id','in',$coupon_id)->order('id desc')->paginate(10)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['start_time'] = date('Y.m.d H:i',$v['start_time']).' - '.date('Y.m.d H:i',$v['end_time']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
318
app/shop/controller/IndexUser.php
Normal file
318
app/shop/controller/IndexUser.php
Normal file
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\ApiRest;
|
||||
|
||||
|
||||
use app\shop\model\IntegralList;
|
||||
use app\shop\model\IntegralLog;
|
||||
|
||||
use app\shop\model\Signin;
|
||||
|
||||
use app\shop\model\SigninRecord;
|
||||
use think\App;
|
||||
use think\Request;
|
||||
|
||||
|
||||
class IndexUser extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $address_model;
|
||||
|
||||
protected $cap_model;
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new \app\farm\model\User();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-03 13:35
|
||||
* @功能说明:积分使用明细
|
||||
*/
|
||||
public function integralList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['user_id','=',$this->getUserId()];
|
||||
|
||||
$dis[] = ['status','=',2];
|
||||
|
||||
$i_model = new IntegralLog();
|
||||
|
||||
// if(!empty($input['add'])&&$input['add']==1){
|
||||
//
|
||||
// $dis[]=['integral_add','>',0];
|
||||
//
|
||||
// }else{
|
||||
//
|
||||
// $dis[]=['integral_add','<',0];
|
||||
// }
|
||||
|
||||
$data = $i_model->integralList($dis,15);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 11:33
|
||||
* @功能说明:积分商城商品列表
|
||||
*/
|
||||
public function integralGoodsList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['c.start_time','<',time()];
|
||||
|
||||
$dis[] = ['c.end_time','>',time()];
|
||||
|
||||
$dis[] = ['c.status','=',1];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
if(!empty($input['goods_name'])){
|
||||
|
||||
$dis[] = ['a.goods_name','like','%'.$input['goods_name'].'%'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['type'])){
|
||||
|
||||
$dis[] = ['c.type','=',$input['type']];
|
||||
|
||||
}
|
||||
|
||||
$i_model = new IntegralList();
|
||||
|
||||
$data = $i_model->integralGoodsList($dis);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 11:44
|
||||
* @功能说明:获取个人信息
|
||||
*/
|
||||
public function userInfo(){
|
||||
|
||||
$data = $this->model->dataInfo(['id'=>$this->getUserId()],'nickName,avatarUrl,integral');
|
||||
|
||||
$signin_model = new Signin();
|
||||
|
||||
$data['signin_integral'] = $signin_model->where(['uniacid'=>$this->_uniacid])->sum('integral');
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 14:14
|
||||
* @功能说明:
|
||||
*/
|
||||
public function signinIndex(){
|
||||
|
||||
$input = $this->_param;
|
||||
//用户积分
|
||||
$user = $this->model->dataInfo(['id'=>$this->getUserId()],'integral,sign_notice,create_time');
|
||||
|
||||
$start_time = strtotime(date("Y-m-01", strtotime($input['day'])));
|
||||
|
||||
$end_time = strtotime(date("Y-m-t", strtotime($input['day'])));
|
||||
|
||||
$i = 0;
|
||||
|
||||
$sign_record_model = new SigninRecord();
|
||||
|
||||
$signin_model = new Signin();
|
||||
|
||||
$sign_record_model->initSign($this->getUserId());
|
||||
|
||||
while ($start_time<=$end_time){
|
||||
|
||||
$list[$i]['day'] = date('d',$start_time)*1;
|
||||
|
||||
$list[$i]['day_str'] = $start_time;
|
||||
|
||||
$list[$i]['week'] = date('w',$start_time);
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'create_date' => date('Y-m-d',$start_time)
|
||||
];
|
||||
|
||||
$find = $sign_record_model->dataInfo($dis);
|
||||
//未在签到时间内
|
||||
if($start_time+86400<$user['create_time']||$start_time>time()){
|
||||
|
||||
$list[$i]['status'] = 2;
|
||||
//已经签到
|
||||
}elseif(!empty($find)){
|
||||
|
||||
$list[$i]['status'] = 1;
|
||||
|
||||
}else{
|
||||
|
||||
$list[$i]['status'] = 0;
|
||||
|
||||
}
|
||||
$start_time+=86400;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $this->getUserId()
|
||||
];
|
||||
|
||||
$arr['list'] = $list;
|
||||
//总签到
|
||||
$arr['total_sign_num'] = $sign_record_model->where($dis)->count();
|
||||
|
||||
$dis['status'] = 1;
|
||||
//连续签到
|
||||
$arr['sign_num'] = $sign_record_model->where($dis)->count();
|
||||
//积分规则
|
||||
$arr['integral_text'] = $signin_model->where(['uniacid'=>$this->_uniacid])->value('text');
|
||||
|
||||
$arr = array_merge($arr,$user);
|
||||
|
||||
return $this->success($arr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 15:24
|
||||
* @功能说明:用户签到
|
||||
*/
|
||||
public function signin(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$sign_record_model = new SigninRecord();
|
||||
|
||||
$signin_model = new Signin();
|
||||
|
||||
$date = date('Y-m-d',$input['day']);
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'create_date' => $date
|
||||
];
|
||||
|
||||
$find = $sign_record_model->dataInfo($dis);
|
||||
|
||||
if(!empty($find)){
|
||||
|
||||
$this->errorMsg('你已经签到过了');
|
||||
}
|
||||
|
||||
if($input['day']+86400<$this->getUserInfo()['create_time']||$input['day']>time()){
|
||||
|
||||
$this->errorMsg('未在签到时间内');
|
||||
|
||||
}
|
||||
//补签
|
||||
if(date('Y-m-d')!=date('Y-m-d',$input['day'])){
|
||||
|
||||
$status = 2;
|
||||
|
||||
}else{
|
||||
|
||||
$status = 1;
|
||||
|
||||
$this->model->dataUpdate(['id'=>$this->getUserId()],['sign_time'=>time()]);
|
||||
}
|
||||
|
||||
$sign_atv = $signin_model->dataInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'create_time' => time(),
|
||||
|
||||
'create_date' => date('Y-m-d',$input['day']),
|
||||
|
||||
'integral' => $sign_atv['integral']
|
||||
];
|
||||
|
||||
$res = $sign_record_model->dataAdd($insert);
|
||||
|
||||
$id = $sign_record_model->getLastInsID();
|
||||
|
||||
$i_log_model = new IntegralLog();
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
//连续签到
|
||||
$sign_atv['times'] = $sign_record_model->where($dis)->count();
|
||||
|
||||
$i_log_model->integralUserAdd($this->getUserId(),$sign_atv['integral'],$this->_uniacid,2,10,$id,0,$sign_atv);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 16:18
|
||||
* @功能说明:签到记录
|
||||
*/
|
||||
public function signinRecordList(){
|
||||
|
||||
$sign_record_model = new SigninRecord();
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $this->getUserId()
|
||||
];
|
||||
|
||||
$data = $sign_record_model->dataList($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
299
app/shop/controller/IndexWxPay.php
Normal file
299
app/shop/controller/IndexWxPay.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
namespace app\shop\controller;
|
||||
use app\AdminRest;
|
||||
use app\ApiRest;
|
||||
use app\farm\model\ClaimOrder;
|
||||
use app\massage\model\Order;
|
||||
use longbingcore\wxcore\PayNotify;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use WxPayApi;
|
||||
|
||||
|
||||
class IndexWxPay extends ApiRest
|
||||
{
|
||||
|
||||
protected $app;
|
||||
public function __construct ( App $app )
|
||||
{
|
||||
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $paymentApp
|
||||
* @param $openid
|
||||
* @param $uniacid
|
||||
* @param $body
|
||||
* @param $attach
|
||||
* @param $totalprice
|
||||
* @throws \WxPayException
|
||||
* 支付
|
||||
*/
|
||||
public function createWeixinPay($paymentApp , $openid , $uniacid , $body , $attach,$totalprice){
|
||||
global $_GPC, $_W;
|
||||
$setting['mini_appid'] = $paymentApp['app_id'];
|
||||
$setting['mini_appsecrept'] = $paymentApp['secret'];
|
||||
$setting['mini_mid'] = $paymentApp['payment']['merchant_id'];
|
||||
$setting['mini_apicode'] = $paymentApp['payment']['key'];
|
||||
$setting['apiclient_cert'] = $paymentApp['payment']['cert_path'];
|
||||
$setting['apiclient_cert_key'] = $paymentApp['payment']['key_path'];
|
||||
define('WX_APPID', $setting['mini_appid']);
|
||||
define('WX_MCHID', $setting['mini_mid']);
|
||||
define('WX_KEY', $setting['mini_apicode']);
|
||||
define('WX_APPSECRET', $setting['mini_appsecrept']);
|
||||
define('WX_SSLCERT_PATH', $setting['apiclient_cert']);
|
||||
define('WX_SSLKEY_PATH', $setting['apiclient_cert_key']);
|
||||
define('WX_CURL_PROXY_HOST', '0.0.0.0');
|
||||
define('WX_CURL_PROXY_PORT', 0);
|
||||
define('WX_REPORT_LEVENL', 0);
|
||||
|
||||
|
||||
require_once PAY_PATH . "/weixinpay/lib/WxPay.Api.php";
|
||||
require_once PAY_PATH . "/weixinpay/example/WxPay.JsApiPay.php";
|
||||
|
||||
$tools = new \JsApiPay();
|
||||
$input = new \WxPayUnifiedOrder();
|
||||
|
||||
$input->SetBody($body);
|
||||
$input->SetAttach(json_encode($attach));
|
||||
$input->SetOut_trade_no($attach['out_trade_no']);
|
||||
$input->SetTotal_fee($totalprice *100);
|
||||
$input->SetTime_start(date("YmdHis"));
|
||||
|
||||
$param_arr=[
|
||||
'i' => $uniacid,
|
||||
't' => $_GPC['t'],
|
||||
'v' => $_GPC['v'],
|
||||
'is_app' => $paymentApp['is_app'],
|
||||
'n' => APP_MODEL_NAME,
|
||||
|
||||
];
|
||||
$reply_path=json_encode($param_arr);
|
||||
//需要判断 是否是微擎的版本
|
||||
if(defined('IS_WEIQIN')){
|
||||
$path = "https://" . $_SERVER['HTTP_HOST'] ."/addons/".APP_MODEL_NAME."/core2/app/Common/wexinPay.php?params=".$reply_path;
|
||||
$paths = "https://" . $_SERVER['HTTP_HOST'] ."/addons/".APP_MODEL_NAME."/core2/app/Common/wexinPay.php?ck=789";
|
||||
$a = file_get_contents($paths);
|
||||
if($a != 1){
|
||||
$this->errorMsg('发起支付失败');
|
||||
}
|
||||
}else{
|
||||
$path = "https://" . $_SERVER['HTTP_HOST'] ."/wexinPay.php?params=".$reply_path;
|
||||
$paths = "https://" . $_SERVER['HTTP_HOST'] ."/wexinPay.php?ck=789";
|
||||
$a = file_get_contents($paths);
|
||||
if($a != 1){
|
||||
$this->errorMsg('发起支付失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this ->lb_logOutput('BaseApiPath:-----'.$path);
|
||||
|
||||
$input->SetNotify_url($path);
|
||||
|
||||
if($paymentApp['is_app']!=1){
|
||||
|
||||
$input->SetTrade_type("JSAPI");
|
||||
|
||||
$input->SetOpenid($openid);
|
||||
|
||||
}else{
|
||||
|
||||
$input->SetTrade_type("APP");
|
||||
|
||||
}
|
||||
|
||||
$order = \WxPayApi::unifiedOrder($input);
|
||||
|
||||
if(!empty($order['return_code'])&&$order['return_code'] == 'FAIL'){
|
||||
|
||||
$this->errorMsg($order['return_msg']);
|
||||
}
|
||||
|
||||
$order['mini_mid'] = $setting['mini_mid'];
|
||||
|
||||
if($paymentApp['is_app']!=1){
|
||||
|
||||
$jsApiParameters = $tools->GetJsApiParameters($order);
|
||||
|
||||
$jsApiParameters = json_decode($jsApiParameters, true) ;
|
||||
|
||||
} else{
|
||||
|
||||
$jsApiParameters = $this->getOrder($order);
|
||||
}
|
||||
|
||||
if (!empty($jsApiParameters['return_code']))
|
||||
$this->errorMsg( '发起支付失败');
|
||||
|
||||
return $jsApiParameters;
|
||||
}
|
||||
|
||||
|
||||
public function getOrder($order)
|
||||
{
|
||||
$data = array(
|
||||
'appid' => WX_APPID,//appid
|
||||
'partnerid' => WX_MCHID,//商户号
|
||||
'timestamp' => time(),//时间戳
|
||||
'noncestr' => WxPayApi::getNonceStr(),//随机字符串
|
||||
'package' => 'Sign=WXPay',//预支付交易会话标识
|
||||
'prepayid' => $order['prepay_id'],//预支付回话标志
|
||||
//'sign_type'=>'MD5'//加密方式
|
||||
);
|
||||
|
||||
$data['paySign'] = $this->makeSign($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* 生成签名
|
||||
* @return 签名,本函数不覆盖sign成员变量,如要设置签名需要调用SetSign方法赋值
|
||||
*/
|
||||
public function makeSign($data)
|
||||
{
|
||||
// 去空
|
||||
$data = array_filter($data);
|
||||
//签名步骤一:按字典序排序参数
|
||||
ksort($data);
|
||||
$string_a = http_build_query($data);
|
||||
$string_a = urldecode($string_a);
|
||||
//签名步骤二:在string后加入KEY
|
||||
|
||||
$string_sign_temp = $string_a . "&key=" . WX_KEY;
|
||||
//签名步骤三:MD5加密
|
||||
$sign = md5($string_sign_temp);
|
||||
// 签名步骤四:所有字符转为大写
|
||||
$result = strtoupper($sign);
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* @param $data
|
||||
* @param int $flag
|
||||
* @return void|null
|
||||
* 打印数据
|
||||
*/
|
||||
|
||||
public function lb_logOutput($data,$flag=0) {
|
||||
if($flag==0){
|
||||
return ;
|
||||
}
|
||||
//数据类型检测
|
||||
if (is_array($data)) {
|
||||
$data = json_encode($data);
|
||||
}
|
||||
$filename = "./".date("Y-m-d").".log";
|
||||
$str = date("Y-m-d H:i:s")." $data"."\r\n";
|
||||
file_put_contents($filename, $str, FILE_APPEND|LOCK_EX);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
|
||||
public function returnPay(){
|
||||
|
||||
|
||||
$this->lb_logOutput("in--mingpianNotify");
|
||||
$xmlData = file_get_contents('php://input');
|
||||
if(empty($xmlData)){
|
||||
$xmlData = 'empty xmlData';
|
||||
}
|
||||
$this->lb_logOutput('xmlData in mingpian:-----'.$xmlData);
|
||||
|
||||
$this->lb_logOutput("in-mingpian2");
|
||||
global $_GPC;
|
||||
$xmlData = file_get_contents('php://input');
|
||||
$this->lb_logOutput('in-mingpian-$xmlData:-----'.$xmlData);
|
||||
//获取配置
|
||||
|
||||
if(defined( 'IS_WEIQIN' )){
|
||||
|
||||
$uniacid=$_GPC['i'];
|
||||
|
||||
$is_app=$_GPC['is_app'];
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$is_app = $_GET['is_app'];
|
||||
|
||||
$uniacid = $_GET['i'];
|
||||
}
|
||||
|
||||
$paymentApp = $this->payConfig($uniacid,$is_app);
|
||||
// dump($paymentApp);exit;
|
||||
$this->lb_logOutput('in-mingpian-uniacid:-----'.$uniacid);
|
||||
|
||||
$setting['mini_appid'] = $paymentApp['app_id'];
|
||||
$setting['mini_appsecrept'] = $paymentApp['secret'];
|
||||
$setting['mini_mid'] = $paymentApp['payment']['merchant_id'];
|
||||
$setting['mini_apicode'] = $paymentApp['payment']['key'];
|
||||
$setting['apiclient_cert'] = $paymentApp['payment']['cert_path'];
|
||||
$setting['apiclient_cert_key'] = $paymentApp['payment']['key_path'];
|
||||
|
||||
define('WX_APPID', $setting['mini_appid']);
|
||||
define('WX_MCHID', $setting['mini_mid']);
|
||||
define('WX_KEY', $setting['mini_apicode']);
|
||||
define('WX_APPSECRET', $setting['mini_appsecrept']);
|
||||
define('WX_SSLCERT_PATH', $setting['apiclient_cert']);
|
||||
define('WX_SSLKEY_PATH', $setting['apiclient_cert_key']);
|
||||
define('WX_CURL_PROXY_HOST', '0.0.0.0');
|
||||
define('WX_CURL_PROXY_PORT', 0);
|
||||
define('WX_REPORT_LEVENL', 0);
|
||||
require_once PAY_PATH.'/weixinpay/lib/WxOrderNotify.php';
|
||||
$WxPay = new \WxOrderNotify($this->app);
|
||||
$WxPay->Handle(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-19 11:26
|
||||
* @功能说明:阿里回调
|
||||
*/
|
||||
public function aliNotify(){
|
||||
|
||||
$data = $_POST;
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$data = $_GET;
|
||||
}
|
||||
|
||||
$pay_config = $this->payConfig();
|
||||
|
||||
require_once EXTEND_PATH.'alipay/aop/AopClient.php';
|
||||
|
||||
$aop = new \AopClient;
|
||||
|
||||
$aop->alipayrsaPublicKey = $pay_config[ 'payment' ][ 'ali_publickey' ];
|
||||
|
||||
$flag = $aop->rsaCheckV1($data, NULL, "RSA2");
|
||||
|
||||
if(!$flag){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$data['flag'] = $flag;
|
||||
|
||||
if(!empty($data)&&$data['trade_status']=='TRADE_SUCCESS') //支付状态
|
||||
{
|
||||
|
||||
$notify_model = new PayNotify();
|
||||
|
||||
$notify_model->aliNotify($data);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user