初始化代码
This commit is contained in:
35
app/shop/config.php
Normal file
35
app/shop/config.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Notes:
|
||||
* User: chenniang
|
||||
* Date: 2019-11-14
|
||||
* Time: 18:32
|
||||
* ${PARAM_DOC}
|
||||
* @return ${TYPE_HINT}
|
||||
* ${THROWS_DOC}
|
||||
*/
|
||||
|
||||
|
||||
$tabbar_shop = [
|
||||
"key" => 20,
|
||||
"is_show" => 1,
|
||||
"iconPath" =>"icon-shangcheng1",
|
||||
"selectedIconPath"=> "icon-shangcheng",
|
||||
"pageComponents" => "shopHome",
|
||||
"name" => "商城",
|
||||
"url" => "/pages/user/home",
|
||||
"url_out" => "",
|
||||
"url_jump_way" => 0
|
||||
];
|
||||
|
||||
$page_shop = [
|
||||
|
||||
];
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'Malls_tabbar' => $tabbar_shop,
|
||||
'Malls_page' => $page_shop
|
||||
|
||||
];
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
596
app/shop/info/AdminMenu.php
Normal file
596
app/shop/info/AdminMenu.php
Normal file
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
$tmp = sassAuth()==1?',{
|
||||
"name": "PurchaseList",
|
||||
"url": "/malls/purchase"
|
||||
}':'';
|
||||
|
||||
$malls = <<<MALLS
|
||||
|
||||
|
||||
{
|
||||
"path": "/malls",
|
||||
"component": "Layout",
|
||||
"redirect": "/malls/list",
|
||||
"meta": {
|
||||
"menuName": "Malls",
|
||||
"icon": "icon-gouwudai",
|
||||
"subNavName": [{
|
||||
"name": "MallsManage",
|
||||
"url": [{
|
||||
"name": "GoodsList",
|
||||
"url": "/malls/list"
|
||||
}, {
|
||||
"name": "GoodsClassify",
|
||||
"url": "/malls/classify"
|
||||
}, {
|
||||
"name": "ParameterManagement",
|
||||
"url": "/malls/parameter"
|
||||
} $tmp
|
||||
]
|
||||
}, {
|
||||
"name": "StoreManage",
|
||||
"url": [{
|
||||
"name": "StoreList",
|
||||
"url": "/malls/storeManage"
|
||||
}]
|
||||
}, {
|
||||
"name": "OrderManage",
|
||||
"url": [{
|
||||
"name": "OrderManage",
|
||||
"url": "/malls/orderManage"
|
||||
}, {
|
||||
"name": "RefundManage",
|
||||
"url": "/malls/refundManage"
|
||||
}]
|
||||
}, {
|
||||
"name": "MarketingManage",
|
||||
"url": [{
|
||||
"name": "AssembleList",
|
||||
"url": "/malls/assemble"
|
||||
}, {
|
||||
"name": "RedPackit",
|
||||
"url": "/malls/redPackit"
|
||||
}]
|
||||
}, {
|
||||
"name": "MallsSet",
|
||||
"url": [{
|
||||
"name": "DealSet",
|
||||
"url": "/malls/dealSet"
|
||||
}, {
|
||||
"name": "VirtualPaymentSet",
|
||||
"url": "/malls/virtualPayment"
|
||||
}, {
|
||||
"name": "StaffChoiceGoods",
|
||||
"url": "/malls/staffGoods"
|
||||
}, {
|
||||
"name": "MallsBanner",
|
||||
"url": "/malls/banner"
|
||||
}]
|
||||
}, {
|
||||
"name": "Distributioninfo",
|
||||
"url": [{
|
||||
"name": "ProfitInfo",
|
||||
"url": "/malls/profit"
|
||||
}, {
|
||||
"name": "CommissionInfo",
|
||||
"url": "/malls/commission"
|
||||
}, {
|
||||
"name": "TakeCashInfo",
|
||||
"url": "/malls/cash"
|
||||
}, {
|
||||
"name": "DistributionRelation",
|
||||
"url": "/malls/relation"
|
||||
}, {
|
||||
"name": "DistributionSetting",
|
||||
"url": "/malls/disSet"
|
||||
}, {
|
||||
"name": "DistributionCash",
|
||||
"url": "/malls/disCash"
|
||||
}, {
|
||||
"name": "DistributionAudit",
|
||||
"url": "/malls/disaudit"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"children": [{
|
||||
"path": "list",
|
||||
"name": "GoodsList",
|
||||
"component": "/malls/goods/list",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "GoodsList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "edit",
|
||||
"name": "GoodsEdit",
|
||||
"component": "/malls/goods/edit",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "GoodsEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "classify",
|
||||
"name": "GoodsClassify",
|
||||
"component": "/malls/goods/classify",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "GoodsClassify",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "addClassify",
|
||||
"name": "SpecsClassify",
|
||||
"component": "/malls/goods/addClassify",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "AddClassify",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "parameter",
|
||||
"name": "ParameterManagement",
|
||||
"component": "/malls/goods/parameter",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "ParameterManagement",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "parimary",
|
||||
"name": "parimar",
|
||||
"component": "/malls/goods/parimary",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "parimar",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "secndparimary",
|
||||
"name": "secndParimar",
|
||||
"component": "/malls/goods/secndparimary",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "secndParimar",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "purchase",
|
||||
"name": "PurchaseList",
|
||||
"component": "/malls/goods/purchase",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "PurchaseList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editPurchase",
|
||||
"name": "PurchaseAdd",
|
||||
"component": "/malls/goods/editPurchase",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "PurchaseAdd",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "wholesale",
|
||||
"name": "WholesaleList",
|
||||
"component": "/malls/goods/wholesale",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "WholesaleList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editWholesale",
|
||||
"name": "WholesaleAdd",
|
||||
"component": "/malls/goods/editWholesale",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "WholesaleAdd",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}
|
||||
,{
|
||||
"path": "storeManage",
|
||||
"name": "StoreList",
|
||||
"component": "/malls/store/list",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "StoreList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "store",
|
||||
"name": "StoreAdd",
|
||||
"component": "/malls/store/edit",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "StoreAdd",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "orderManage",
|
||||
"name": "OrderManage",
|
||||
"component": "/malls/order/manage",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "OrderManage",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "orderDetail",
|
||||
"name": "OrderDetail",
|
||||
"component": "/malls/order/detail",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "OrderDetail",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "refundManage",
|
||||
"name": "RefundManage",
|
||||
"component": "/malls/order/refund",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "RefundManage",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "newAssemble",
|
||||
"name": "NewAssemble",
|
||||
"component": "/malls/marketing/newAssemble",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "NewAssemble",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "assemble",
|
||||
"name": "AssembleList",
|
||||
"component": "/malls/marketing/assemble",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "AssembleList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "assembleManage",
|
||||
"name": "AssembleManage",
|
||||
"component": "/malls/marketing/assembleManage",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "AssembleManage",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "redPackit",
|
||||
"name": "RedPackit",
|
||||
"component": "/malls/marketing/redPackit",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "RedPackit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "addRedPackit",
|
||||
"name": "EditRedPackit",
|
||||
"component": "/malls/marketing/addRedPackit",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "EditRedPackit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "dealSet",
|
||||
"name": "DealSet",
|
||||
"component": "/malls/set/deal",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "DealSet",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "virtualPayment",
|
||||
"name": "VirtualPaymentSet",
|
||||
"component": "/malls/set/payment",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VirtualPaymentSet",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "banner",
|
||||
"name": "MallsBanner",
|
||||
"component": "/malls/set/banner",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "MallsBanner",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editBanner",
|
||||
"name": "EditBanner",
|
||||
"component": "/malls/set/editBanner",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "EditBanner",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "staffGoods",
|
||||
"name": "StaffChoiceGoods",
|
||||
"component": "/malls/set/staffGoods",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "StaffChoiceGoods",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "profit",
|
||||
"component": "/malls/distribution/profit",
|
||||
"name": "ProfitInfo",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"keepAlive": true,
|
||||
"pagePermission": [{
|
||||
"title": "ProfitInfo",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "commission",
|
||||
"component": "/malls/distribution/commission",
|
||||
"name": "CommissionInfo",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"keepAlive": true,
|
||||
"pagePermission": [{
|
||||
"title": "CommissionInfo",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "cash",
|
||||
"component": "/malls/distribution/takeCash",
|
||||
"name": "TakeCashInfo",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"keepAlive": true,
|
||||
"pagePermission": [{
|
||||
"title": "TakeCashInfo",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "relation",
|
||||
"component": "/malls/distribution/relation",
|
||||
"name": "DistributionRelation",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"keepAlive": true,
|
||||
"pagePermission": [{
|
||||
"title": "DistributionRelation",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "disSet",
|
||||
"component": "/malls/distribution/set",
|
||||
"name": "DistributionSetting",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"pagePermission": [{
|
||||
"title": "DistributionSetting",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "disCash",
|
||||
"component": "/malls/distribution/cash",
|
||||
"name": "DistributionCash",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"pagePermission": [{
|
||||
"title": "DistributionCash",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "disaudit",
|
||||
"component": "/malls/distribution/audit",
|
||||
"name": "DistributionAudit",
|
||||
"meta": {
|
||||
"title": "MallsManage",
|
||||
"auth": [],
|
||||
"isOnly": false,
|
||||
"pagePermission": [{
|
||||
"title": "DistributionAudit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
MALLS;
|
||||
|
||||
//return json_decode($menu, true) ;
|
||||
|
||||
return ["shop" => $malls];
|
||||
|
||||
|
||||
51
app/shop/info/DiyCompoents.php
Normal file
51
app/shop/info/DiyCompoents.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
$goods = <<<GOODS
|
||||
{
|
||||
"title":"商品列表",
|
||||
"type":"goodsList",
|
||||
"icon":"iconGoodsList",
|
||||
"isDelete":true,
|
||||
"addNumber":1,
|
||||
"attr":[
|
||||
],
|
||||
"data":{
|
||||
"title":"商品列表",
|
||||
"isShowPush":false,
|
||||
"limit":""
|
||||
},
|
||||
"dataList":[
|
||||
]
|
||||
}
|
||||
|
||||
GOODS;
|
||||
|
||||
$search = <<<SEARCH
|
||||
{"title":"搜索栏","type":"search","iconPath":"iconsousuo","isDelete":true,"addNumber":1,"attr":[{"title":"是否显示分类","type":"Switch","name":"isShowCateAll"}],"data":{"placeholder":"请输入搜索内容","isShowCateAll":true}}
|
||||
|
||||
SEARCH;
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
return [
|
||||
|
||||
[
|
||||
"title" => "业务组件",
|
||||
|
||||
'type' => 'shopCompoent',
|
||||
|
||||
'data' =>[
|
||||
|
||||
json_decode($search, true),
|
||||
|
||||
json_decode($goods, true),
|
||||
|
||||
]
|
||||
],
|
||||
];
|
||||
276
app/shop/info/DiyDefaultCompoents.php
Normal file
276
app/shop/info/DiyDefaultCompoents.php
Normal file
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
$defaultPage=<<<DEFAULT
|
||||
|
||||
{
|
||||
"key": 2,
|
||||
"list": [{
|
||||
"title": "搜索栏",
|
||||
"type": "search",
|
||||
"iconPath": "iconsousuo",
|
||||
"isDelete": true,
|
||||
"addNumber": 1,
|
||||
"attr": [{
|
||||
"title": "是否显示全部分类",
|
||||
"type": "Switch",
|
||||
"name": "isShowCateAll"
|
||||
}],
|
||||
"data": {
|
||||
"placeholder": "请输入搜索内容",
|
||||
"isShowCateAll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "轮播图",
|
||||
"type": "banner",
|
||||
"icon": "iconlunbo",
|
||||
"isDelete": true,
|
||||
"addNumber": 9999,
|
||||
"attr": [{
|
||||
"title": "选择模板",
|
||||
"type": "ChooseModule",
|
||||
"name": "bannerName",
|
||||
"data": [{
|
||||
"title": "通屏轮播",
|
||||
"name": "banner-tongping",
|
||||
"img": "http://longbingcdn.xiaochengxucms.com/admin/diy/banner-tongping.png"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"title": "图片列表",
|
||||
"type": "ImageLink",
|
||||
"name": "bannerList",
|
||||
"isDraggable": true,
|
||||
"isDelete": true,
|
||||
"data": [{
|
||||
"title": "图片",
|
||||
"type": "UploadImage",
|
||||
"name": "img",
|
||||
"desc": "750*350"
|
||||
},
|
||||
{
|
||||
"title": "链接类型",
|
||||
"type": "Select",
|
||||
"name": "linkType",
|
||||
"data": [{
|
||||
"label": "小程序内部页面",
|
||||
"value": 4
|
||||
},
|
||||
{
|
||||
"label": "其他小程序",
|
||||
"value": 2
|
||||
},
|
||||
{
|
||||
"label": "跳转网页",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"label": "拨打电话",
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "链接地址",
|
||||
"type": "Tag",
|
||||
"name": "link"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "添加模板",
|
||||
"type": "Add",
|
||||
"name": "addMouduleName",
|
||||
"addNumber": 10,
|
||||
"data": [{
|
||||
"link": [{
|
||||
"title": ""
|
||||
}],
|
||||
"linkType": 4,
|
||||
"img": [{
|
||||
"url": "http://longbingcdn.xiaochengxucms.com/admin/diy/default.png"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"style": {
|
||||
"height": 350,
|
||||
"whiteSpace": 0,
|
||||
"wingBlank": 0
|
||||
},
|
||||
"bannerName": "banner-tongping",
|
||||
"addMouduleName": "bannerList",
|
||||
"bannerList": []
|
||||
},
|
||||
"id": 1591856492396,
|
||||
"compontents": "base"
|
||||
},
|
||||
{
|
||||
"title": "导航",
|
||||
"type": "column",
|
||||
"icon": "icondaohang1",
|
||||
"isDelete": true,
|
||||
"addNumber": 9999,
|
||||
"attr": [{
|
||||
"title": "多少行",
|
||||
"type": "InputNumber",
|
||||
"name": "row"
|
||||
},
|
||||
{
|
||||
"title": "每行多少列",
|
||||
"type": "InputNumber",
|
||||
"name": "col"
|
||||
},
|
||||
{
|
||||
"title": "图片列表",
|
||||
"type": "ImageLink",
|
||||
"name": "columnList",
|
||||
"isDraggable": true,
|
||||
"isDelete": true,
|
||||
"data": [{
|
||||
"title": "按钮文字",
|
||||
"type": "Input",
|
||||
"name": "title"
|
||||
},
|
||||
{
|
||||
"title": "图片",
|
||||
"type": "UploadImage",
|
||||
"name": "img",
|
||||
"desc": "100*100"
|
||||
},
|
||||
{
|
||||
"title": "链接类型",
|
||||
"type": "Select",
|
||||
"name": "linkType",
|
||||
"data": [{
|
||||
"label": "小程序内部页面",
|
||||
"value": 4
|
||||
},
|
||||
{
|
||||
"label": "其他小程序",
|
||||
"value": 2
|
||||
},
|
||||
{
|
||||
"label": "跳转网页",
|
||||
"value": 3
|
||||
},
|
||||
{
|
||||
"label": "拨打电话",
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "链接地址",
|
||||
"type": "Tag",
|
||||
"name": "link"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "添加模板",
|
||||
"type": "Add",
|
||||
"name": "addMouduleName",
|
||||
"addNumber": 16,
|
||||
"data": [{
|
||||
"link": [{
|
||||
"title": ""
|
||||
}],
|
||||
"linkType": 4,
|
||||
"img": [{
|
||||
"url": "http://longbingcdn.xiaochengxucms.com/admin/diy/default.png"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"row": {
|
||||
"number": 2,
|
||||
"min": 1,
|
||||
"max": 2
|
||||
},
|
||||
"col": {
|
||||
"number": 4,
|
||||
"min": 4,
|
||||
"max": 5
|
||||
},
|
||||
"style": {
|
||||
"fontColor": "#666",
|
||||
"background": "#ffffff",
|
||||
"whiteSpace": 30,
|
||||
"wingBlank": 0
|
||||
},
|
||||
"addMouduleName": "columnList",
|
||||
"columnList": []
|
||||
},
|
||||
"id": 1591856495749,
|
||||
"compontents": "base"
|
||||
},
|
||||
{
|
||||
"title": "卡券",
|
||||
"type": "couponList",
|
||||
"icon": "iconCouponList",
|
||||
"isDelete": true,
|
||||
"addNumber": 1,
|
||||
"attr": [{
|
||||
"title": "模板名称",
|
||||
"type": "Input",
|
||||
"name": "title",
|
||||
"maxLength": 10
|
||||
},
|
||||
{
|
||||
"title": "卡券样式",
|
||||
"type": "Radio",
|
||||
"name": "type",
|
||||
"data": [{
|
||||
"label": 1,
|
||||
"title": "弹窗样式"
|
||||
},
|
||||
{
|
||||
"label": 2,
|
||||
"title": "列表样式"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"title": "领取卡券",
|
||||
"type": 2,
|
||||
"dataList": []
|
||||
},
|
||||
"id": 1591856498485,
|
||||
"compontents": "operate"
|
||||
},
|
||||
{
|
||||
"title": "商品列表",
|
||||
"type": "goodsList",
|
||||
"icon": "iconGoodsList",
|
||||
"isDelete": true,
|
||||
"addNumber": 1,
|
||||
"attr": [],
|
||||
"data": {
|
||||
"title": "商品列表",
|
||||
"limit": "",
|
||||
"dataList": []
|
||||
},
|
||||
"id": 1591856499273,
|
||||
"compontents": "shopCompoent"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DEFAULT;
|
||||
|
||||
|
||||
$pages = json_decode( $defaultPage , true);
|
||||
|
||||
|
||||
return $pages;
|
||||
46
app/shop/info/DiyLink.php
Normal file
46
app/shop/info/DiyLink.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
return [
|
||||
//链接类型
|
||||
[
|
||||
'key' => 2,
|
||||
"title" => "商城",
|
||||
"type" => "shop",
|
||||
"data" => [
|
||||
[
|
||||
//接口请求路径 api_path 不为空, 返回 page + '?' 数据参数
|
||||
"api_path" => "/diy/admin/Module/functionPage",
|
||||
//已经取消了
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "功能页面",
|
||||
//小程序路径
|
||||
"page" => "common_page"
|
||||
],[
|
||||
//接口请求路径 api_path 不为空, 返回 page + '?' 数据参数
|
||||
"api_path" => "/shop/admin/AdminShopType/cateInfoPage",
|
||||
//已经取消了
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商品分类页面",
|
||||
//小程序路径
|
||||
"page" => "/shop/pages/filter"
|
||||
],[
|
||||
//接口请求路径 api_path 不为空, 返回 page + '?' 数据参数
|
||||
"api_path" => "/shop/admin/AdminShopGoods/goodsInfoPage",
|
||||
//已经取消了
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商品详情页面",
|
||||
//小程序路径
|
||||
"page" => "/pages/shop/detail"
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
42
app/shop/info/DiyTabbar.php
Normal file
42
app/shop/info/DiyTabbar.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
//底部菜单自定义
|
||||
return [
|
||||
[
|
||||
//底部菜单编号
|
||||
'key' => 2 ,
|
||||
//是否显示
|
||||
'is_show' => 1 ,
|
||||
//图标
|
||||
'iconPath' => 'icon-shangcheng1',
|
||||
//选中图标样式
|
||||
'selectedIconPath' => 'icon-shangcheng',
|
||||
//那个页面 英文名称
|
||||
'pageComponents' => 'shopHome',
|
||||
//名称
|
||||
'name' => '商城',
|
||||
'url' => '',
|
||||
'url_jump_way' => '0',
|
||||
'url_out' => '',
|
||||
'is_delete' => false ,
|
||||
'bind_compoents'=>[
|
||||
'base',
|
||||
'shopCompoent',
|
||||
'operate'
|
||||
],
|
||||
|
||||
'bind_links' => [
|
||||
|
||||
'shop'
|
||||
],
|
||||
'page'=> []
|
||||
],
|
||||
|
||||
];
|
||||
86
app/shop/info/FunctionPage.php
Normal file
86
app/shop/info/FunctionPage.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//模块组件 后台DIY页面的左侧
|
||||
$tmp = [
|
||||
//链接类型
|
||||
|
||||
[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>1,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城页面",
|
||||
//小程序路径
|
||||
"path" => "/pages/user/home?key=2&staff_id="
|
||||
],[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>2,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城购物车",
|
||||
//小程序路径
|
||||
"path" => "/shop/pages/cart"
|
||||
],[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>2,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城卡券列表",
|
||||
//小程序路径
|
||||
"path" => "/shop/pages/coupon/receive?staff_id="
|
||||
],
|
||||
|
||||
[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>2,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城全部分类",
|
||||
//小程序路径
|
||||
"path" => "/shop/pages/cate"
|
||||
],
|
||||
[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>2,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城采购模版",
|
||||
//小程序路径
|
||||
"path" => "/shop/pages/purchase/list?staff_id="
|
||||
],
|
||||
[
|
||||
'id'=>'',
|
||||
|
||||
'level'=>2,
|
||||
|
||||
'key'=> 2,
|
||||
//"params"=>"{"page" : "PAGE", "page_count" : "PAGE_COUNT"}",
|
||||
"title" => "商城砍价列表页",
|
||||
//小程序路径
|
||||
"path" => "/shop/pages/bargain/list?staff_id="
|
||||
],
|
||||
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
||||
return $tmp;
|
||||
32
app/shop/info/Info.php
Normal file
32
app/shop/info/Info.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:30
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
//模块名称[必填]
|
||||
'name' => 'shop',
|
||||
//模块标题[必填]
|
||||
'title' =>'商城',
|
||||
//内容简介
|
||||
'desc' =>'',
|
||||
//封面图标
|
||||
'icon' =>'',
|
||||
//模块类型[必填] model:模块 可以出现在左侧一级 app:应用中心 , 是一个应用中心的应用
|
||||
'type' => 'model',
|
||||
// 模块唯一标识[必填],格式:模块名.开发者标识.module
|
||||
'identifier' => 'shop.longbing.module',
|
||||
// 版本[必填],格式采用三段式:主版本号.次版本号.修订版本号
|
||||
'version' => '1.0.80',
|
||||
// 模块依赖[可选],格式[[模块名, 模块唯一标识, 依赖版本, 对比方式]]
|
||||
'need_module'=> [],
|
||||
// 应用依赖[可选],格式[[插件名, 应用唯一标识, 依赖版本, 对比方式]]
|
||||
'need_app' => [],
|
||||
//订阅消息
|
||||
'tmpl_name'=>['pay_order','send_order','land_order','land_over']
|
||||
|
||||
];
|
||||
106
app/shop/info/PermissionShop.php
Normal file
106
app/shop/info/PermissionShop.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace app\shop\info;
|
||||
|
||||
use longbingcore\permissions\PermissionAbstract;
|
||||
|
||||
/**
|
||||
* 商城模块功能权限
|
||||
* Class PermissionAppstore
|
||||
*/
|
||||
class PermissionShop extends PermissionAbstract {
|
||||
|
||||
const tabbarKey = null;
|
||||
//后台管理菜单对应key[必填] , 当前模块文件夹名称
|
||||
const adminMenuKey = 'shop';
|
||||
public $saasKey ;
|
||||
const apiPaths = [];
|
||||
|
||||
|
||||
public function __construct(int $uniacid,$infoConfigOptions = [])
|
||||
{
|
||||
$this->saasKey = longbing_get_auth_prefix('AUTH_SHOP') ;
|
||||
parent::__construct($uniacid, self::tabbarKey, self::adminMenuKey, $this->saasKey, self::apiPaths , $infoConfigOptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回saas端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function sAuth(): bool
|
||||
{
|
||||
if(!$this->getAuthIsSaasCheck()){
|
||||
return true ;
|
||||
}
|
||||
return $this->sassValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回p端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function pAuth(): bool
|
||||
{
|
||||
if (!$this->sAuth()) {
|
||||
return false;
|
||||
};
|
||||
|
||||
//代理管理端可以控制商城是否展示权限 , 这里需要判断权限
|
||||
$pAuthConfig = $this->getPAuthConfig();
|
||||
//必须平台授权才能使用
|
||||
|
||||
//dump($this->getAuthIsPlatformCheck());exit;
|
||||
if($this->getAuthIsPlatformCheck()){
|
||||
//根据授权而定
|
||||
if ($pAuthConfig ){
|
||||
|
||||
// dump($pAuthConfig);exit;
|
||||
return $pAuthConfig['shop_switch'] ? true : false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回c端授权结果
|
||||
*
|
||||
* @param int $user_id
|
||||
* @return bool
|
||||
* @author ArtizanZhang
|
||||
* @DataTime: 2019/12/9 17:13
|
||||
*/
|
||||
public function cAuth(int $user_id): bool
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品数量
|
||||
*
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/19 19:02
|
||||
*/
|
||||
public function getAddGoodsNumber(){
|
||||
return $this->getAuthVaule( longbing_get_auth_prefix('AUTH_GOODS') , 4);
|
||||
|
||||
}
|
||||
}
|
||||
204
app/shop/info/RadarMessage.php
Normal file
204
app/shop/info/RadarMessage.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
$radar_msg = [
|
||||
[
|
||||
"sign"=> "copy",
|
||||
"type"=> 8,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请及时留意雷达动态",
|
||||
"operation"=> "咨询",
|
||||
"item"=> "产品",
|
||||
"show_count"=> 1,
|
||||
"table_name"=> "",
|
||||
"field"=> "",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 1,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请尽快把握商机",
|
||||
"operation"=> "浏览",
|
||||
"item"=> "商城列表",
|
||||
"show_count"=> 1,
|
||||
"table_name"=> "longbing_card_shop_type",
|
||||
"field"=> "title",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 2,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请尽快把握商机,主动提供细致的商品讲解将大大有利于成交",
|
||||
"operation"=> "正在查看",
|
||||
"item"=> "商品",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_goods",
|
||||
"field"=> "name",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 11,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请尽快把握商机",
|
||||
"operation"=> "浏览",
|
||||
"item"=> "商品分类列表",
|
||||
"show_count"=> 1,
|
||||
"table_name"=> "longbing_card_shop_type",
|
||||
"field"=> "title",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 19,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请前往订单中心查看详情",
|
||||
"operation"=> "订单商品已发货,系统订单号为:",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 20,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请前往订单中心查看详情",
|
||||
"operation"=> "自提商品已提货",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 21,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请等待管理员审核并注意查收",
|
||||
"operation"=> "已申请退款",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 22,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请前往订单中心查看详情",
|
||||
"operation"=> "已取消申请退款",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 23,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请前往订单中心查看详情",
|
||||
"operation"=> "管理员拒绝退款",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "view",
|
||||
"type"=> 24,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请注意查收",
|
||||
"operation"=> "退款成功",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 1,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "order",
|
||||
"type"=> 1,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请在订单中心查看详情",
|
||||
"operation"=> "已购买商品",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 2,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "order",
|
||||
"type"=> 2,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请在订单中心查看详情",
|
||||
"operation"=> "已参与拼团",
|
||||
"item"=> "",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "longbing_card_shop_order",
|
||||
"field"=> "out_trade_no",
|
||||
"send"=> 2,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
[
|
||||
"sign"=> "order",
|
||||
"type"=> 3,
|
||||
"max"=> 0,
|
||||
"pid"=> 0,
|
||||
"msg"=> "请在预约订单中心查看详情",
|
||||
"operation"=> "预约了",
|
||||
"item"=> "服务",
|
||||
"show_count"=> 0,
|
||||
"table_name"=> "lb_appoint_record",
|
||||
"field"=> "name,phone,project_id,start_time,remark",
|
||||
"send"=> 2,
|
||||
"uniacid"=> 2,
|
||||
"status"=> 1
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
||||
return $radar_msg;
|
||||
455
app/shop/info/Subscribe.php
Normal file
455
app/shop/info/Subscribe.php
Normal file
@@ -0,0 +1,455 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\shop\info;
|
||||
|
||||
use app\bargain\info\PermissionBargain;
|
||||
use app\card\model\CardExtension;
|
||||
use app\radar\model\RadarOrder;
|
||||
use app\shop\model\IndexShopCollage;
|
||||
use longbingcore\diy\BaseSubscribe;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/11 16:23
|
||||
* Class Subscribe
|
||||
* @package app\ucenter\info
|
||||
*/
|
||||
class Subscribe extends BaseSubscribe
|
||||
{
|
||||
|
||||
/**
|
||||
* 相应个人中心工具菜单
|
||||
*
|
||||
* @return mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/12 11:24
|
||||
*/
|
||||
public function onAddWorkCenterModelMenu()
|
||||
{
|
||||
|
||||
$permissson = new PermissionShop($this->_uniacid);
|
||||
if($permissson->pAuth()) {
|
||||
|
||||
$modelMenu = [
|
||||
"title" => '商品服务',
|
||||
"desc" => '',
|
||||
"show" => true,
|
||||
"row" => 4,
|
||||
"list" => [
|
||||
[
|
||||
"title" => "我的收入",
|
||||
"icon" => "icontixianguanli",
|
||||
"link" => "/shop/pages/partner/income",
|
||||
"linkType" => 4
|
||||
],
|
||||
[
|
||||
"title" => "订单管理",
|
||||
"icon" => "iconwodedingdan",
|
||||
"link" => "/shop/pages/order/list?target=staff",
|
||||
"linkType" => 4
|
||||
],
|
||||
[
|
||||
"title" => "退款管理",
|
||||
"icon" => "iconwodeshouhou",
|
||||
"link" => "/shop/pages/refund/list?target=staff",
|
||||
"linkType" => 4
|
||||
],
|
||||
[
|
||||
"title" => "推荐商品",
|
||||
"icon" => "icontuijianshangpin",
|
||||
"link" => "/shop/pages/staff/goods/push",
|
||||
"linkType" => 4
|
||||
],
|
||||
[
|
||||
"title" => "卡券管理",
|
||||
"icon" => "iconwodekaquan",
|
||||
"link" => "/shop/pages/staff/coupon/list",
|
||||
"linkType" => 4
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return [$modelMenu];
|
||||
}
|
||||
return [];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 名片展示页获取其他模块数据
|
||||
*
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/24 14:24
|
||||
*/
|
||||
public function onCardInfo($params)
|
||||
{
|
||||
|
||||
//获取推荐商品 By.jingshuixian
|
||||
$modelExtension = new CardExtension();
|
||||
$goods_list = $modelExtension->cardExtensionList($params['staff_id'], $this->_uniacid);
|
||||
|
||||
$collage_model = new IndexShopCollage();
|
||||
foreach ($goods_list as $key => $val) {
|
||||
$goods_list[$key]['is_collage'] = 0;
|
||||
$count = $collage_model->getCollage(['goods_id' => $val['id'], 'uniacid' => $this->_uniacid, 'status' => 1]);
|
||||
if (!empty($count)) $goods_list[$key]['is_collage'] = 1;
|
||||
}
|
||||
|
||||
return ['goods_list'=>$goods_list];
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户获取列表查询
|
||||
*
|
||||
* @param $data
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/26 10:30
|
||||
*/
|
||||
public function onStaffCustomerList($data)
|
||||
{
|
||||
// 商城订单
|
||||
$orderCount = RadarOrder::where( [ [ 'pay_status', '=', 1 ],
|
||||
[ 'order_status', '<>', 1 ],
|
||||
[ 'user_id', '=', $data[ 'uid' ] ],
|
||||
[ 'to_uid', '=', $data[ 'to_uid' ]],
|
||||
[ 'refund_status', '=', 0 ] ]
|
||||
)
|
||||
->count();
|
||||
|
||||
$returnData[ 'count' ] = $orderCount;
|
||||
$returnData[ 'title' ] = "订单";
|
||||
|
||||
return [$returnData];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @功能说明:处理一下数据 主要是权限方面的
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-12-16 16:21
|
||||
*/
|
||||
public function onDiyModuleMenuShop($data){
|
||||
|
||||
|
||||
if(!empty($data['data']['list'])){
|
||||
|
||||
foreach ($data['data']['list'] as $v){
|
||||
|
||||
if($v['icon']!='icontemplate'||$data['shop_auth']==true){
|
||||
|
||||
$arr[] = $v;
|
||||
}
|
||||
|
||||
}
|
||||
$data['data']['list'] = $arr;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监听用户中心模块
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/18 14:04
|
||||
*/
|
||||
public function onAddUcenterCompoent(){
|
||||
$this->getUserId();
|
||||
|
||||
$user = longbingGetUserInfo($this->getUserId() , $this->_uniacid);
|
||||
|
||||
$last_staff_id = !empty($user['last_staff_id'])?$user['last_staff_id']:0;
|
||||
|
||||
$moduleMenuShopOrder = <<<COMPOENT
|
||||
{
|
||||
"title": "商城订单",
|
||||
"type": "moduleMenuShopOrder",
|
||||
"icon": "iconshoporder",
|
||||
"isDelete": true,
|
||||
"addNumber": 1,
|
||||
"attr": [
|
||||
{
|
||||
"title": "模板名称",
|
||||
"type": "Switch",
|
||||
"name": "isShowTitle"
|
||||
},
|
||||
{
|
||||
"title": "选择模板",
|
||||
"type": "ChooseModule",
|
||||
"name": "module",
|
||||
"data": [
|
||||
{
|
||||
"title": "一行多列",
|
||||
"name": "module-menu-row",
|
||||
"img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-col.jpg"
|
||||
},
|
||||
{
|
||||
"title": "一行一列",
|
||||
"name": "module-menu-col",
|
||||
"img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-row.jpg"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "一行多少列",
|
||||
"type": "InputNumber",
|
||||
"name": "row"
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"isShowTitle": false,
|
||||
"module": "module-menu-row",
|
||||
"row": {
|
||||
"number": 4,
|
||||
"min": 2,
|
||||
"max": 5,
|
||||
"label": "请输入"
|
||||
},
|
||||
"list": [
|
||||
{
|
||||
"title": "全部",
|
||||
"icon": "iconwodedingdan",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/order/list?index=0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "待付款",
|
||||
"icon": "icondingdandaifukuan",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/order/list?index=1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "待发货",
|
||||
"icon": "icondingdandaifahuo",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/order/list?index=2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "待收货",
|
||||
"icon": "icondingdandaishouhuo",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/order/list?index=3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "已完成",
|
||||
"icon": "icondingdanyiwancheng",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/order/list?index=4"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
COMPOENT;
|
||||
|
||||
$tmp = sassAuth()==1?',
|
||||
{
|
||||
|
||||
"title": "我的采购模板",
|
||||
|
||||
"icon": "icontemplate",
|
||||
|
||||
"link": {
|
||||
|
||||
"type": 2,
|
||||
|
||||
"url": "/shop/pages/purchase/list?staff_id='.$last_staff_id.'"'.'
|
||||
}
|
||||
}':'';
|
||||
|
||||
|
||||
|
||||
$bargain_p = new PermissionBargain($this->_uniacid);
|
||||
|
||||
$bargain_auth = $bargain_p->pAuth();
|
||||
|
||||
$bargain = $bargain_auth==true?',
|
||||
{
|
||||
"title": "我的砍价",
|
||||
"icon": "iconkanjiajilu",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/bargain/record"
|
||||
}
|
||||
}':'';
|
||||
|
||||
$moduleMenuShop = <<<COMPOENT
|
||||
{
|
||||
"title": "商城工具",
|
||||
"type": "moduleMenuShop",
|
||||
"icon": "iconshop",
|
||||
"isDelete": true,
|
||||
"addNumber": 1,
|
||||
"attr": [
|
||||
{
|
||||
"title": "模板名称",
|
||||
"type": "Switch",
|
||||
"name": "isShowTitle"
|
||||
},
|
||||
{
|
||||
"title": "选择模板",
|
||||
"type": "ChooseModule",
|
||||
"name": "module",
|
||||
"data": [
|
||||
{
|
||||
"title": "一行多列",
|
||||
"name": "module-menu-row",
|
||||
"img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-col.jpg"
|
||||
},
|
||||
{
|
||||
"title": "一行一列",
|
||||
"name": "module-menu-col",
|
||||
"img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-row.jpg"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "一行多少列",
|
||||
"type": "InputNumber",
|
||||
"name": "row"
|
||||
}
|
||||
],
|
||||
"data": {
|
||||
"isShowTitle": false,
|
||||
"module": "module-menu-row",
|
||||
"row": {
|
||||
"number": 4,
|
||||
"min": 2,
|
||||
"max": 5,
|
||||
"label": "请输入"
|
||||
},
|
||||
"list": [
|
||||
{
|
||||
"title": "我的售后",
|
||||
"icon": "iconwodeshouhou",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/refund/list"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "我的收入",
|
||||
"icon": "icontixianguanli",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/partner/income"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "我的卡券",
|
||||
"icon": "iconwodekaquan",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/coupon/list"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "分销商品",
|
||||
"icon": "iconquanmianfenxiao",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"needStaffId": true,
|
||||
"url": "/shop/pages/partner/distribution?staff_id=$last_staff_id"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "我的地址",
|
||||
"icon": "icondizhi2",
|
||||
"link": {
|
||||
"type": 2,
|
||||
"url": "/shop/pages/address/list"
|
||||
}
|
||||
}$bargain
|
||||
$tmp
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
COMPOENT;
|
||||
|
||||
|
||||
$permission = new PermissionShop($this->_uniacid);
|
||||
$compoentList = [] ;
|
||||
if($permission->pAuth()){
|
||||
$compoentList = [
|
||||
json_decode($moduleMenuShopOrder, true),
|
||||
json_decode($moduleMenuShop, true)
|
||||
] ;
|
||||
}
|
||||
|
||||
return $compoentList ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 监听代理管理端授权小程序事件
|
||||
*
|
||||
* @param $data
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/27 17:33
|
||||
*/
|
||||
public function onAgentAppAuthEdit($config){
|
||||
|
||||
|
||||
$returnArr = [] ;
|
||||
|
||||
$permission = new PermissionShop(0);
|
||||
$shop_switch = [] ;
|
||||
if($permission->sAuth() && $permission->infoConfig['auth_platform'] ) {
|
||||
|
||||
$shop_switch['formType'] = 'radio';
|
||||
$shop_switch['name'] = 'shop_switch';
|
||||
|
||||
$shop_switch['value'] = $config ? $config[ $shop_switch['name'] ] : 0;
|
||||
$shop_switch['title'] = $permission->info['title'];
|
||||
$returnArr[] = $shop_switch;
|
||||
}
|
||||
|
||||
|
||||
$pay_shop = [] ;
|
||||
if($permission->sAuth() && $permission->infoConfig['auth_platform'] ) {
|
||||
|
||||
$pay_shop['formType'] = 'radio';
|
||||
$pay_shop['name'] = 'pay_shop';
|
||||
|
||||
$pay_shop['value'] = $config ? $config[ $pay_shop['name'] ] : 0;
|
||||
$pay_shop['title'] = $permission->info['title'].'支付';
|
||||
$returnArr[] = $pay_shop;
|
||||
}
|
||||
|
||||
return $returnArr ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
0
app/shop/info/UpdateSql.php
Normal file
0
app/shop/info/UpdateSql.php
Normal file
15
app/shop/lang/zh-cn.php
Normal file
15
app/shop/lang/zh-cn.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
return [
|
||||
'not find refundorder' => '未找到退款订单',
|
||||
'not find order' => '未找到订单',
|
||||
'status is error' => '状态错误',
|
||||
'Too little money' => '体现金额不得小于平台最低提现金额',
|
||||
'no profit' => '未找到佣金记录',
|
||||
'Insufficient amount' => '佣金不足',
|
||||
'no data' => '未找到记录',
|
||||
'not data' => '未找到记录',
|
||||
'Only offline package can be cancelled' => '只有线下福包才能核销',
|
||||
'The coupon has expired'=> '福包已过期',
|
||||
'not find card' => '名片没有找到',
|
||||
'no config of pay' => '未配置支付信息',
|
||||
];
|
||||
550
app/shop/model/DistributionCash.php
Normal file
550
app/shop/model/DistributionCash.php
Normal file
@@ -0,0 +1,550 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\Claim;
|
||||
use app\farm\model\LandList;
|
||||
use app\farm\model\ShopGoods;
|
||||
use app\farm\model\User;
|
||||
use app\farm\server\Land;
|
||||
use think\facade\Db;
|
||||
|
||||
class DistributionCash extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected $name = 'lbfarm_v2_distribution_cash_list';
|
||||
|
||||
protected $append = [
|
||||
|
||||
'order_goods'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:商品详情
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 17:44
|
||||
*/
|
||||
public function getOrderGoodsAttr($value,$data){
|
||||
|
||||
if(!empty($data['type'])&&!empty($data['id'])){
|
||||
|
||||
$goods_model = new DistributionGoods();
|
||||
|
||||
if($data['type']==1){
|
||||
|
||||
$list = $goods_model->getShopGoods($data['id']);
|
||||
|
||||
}elseif($data['type']==2){
|
||||
|
||||
$list = $goods_model->getLandGoods($data['id']);
|
||||
|
||||
}else{
|
||||
|
||||
$list = $goods_model->getCliamGoods($data['id']);
|
||||
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 17:02
|
||||
*/
|
||||
public function returnType($type){
|
||||
|
||||
switch ($type){
|
||||
|
||||
case 1:
|
||||
|
||||
$text = '商城产品';
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
$text = '土地产品';
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
$text = '认养产品';
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
$text = '商城产品';
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page=10){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @param $type
|
||||
* @param int $status
|
||||
* @功能说明:添加商城分销记录
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 13:51
|
||||
*/
|
||||
public function addUserCashShop($fx_id,$top_id,$order,$type,$status=1){
|
||||
|
||||
|
||||
if(!empty($order['order_goods'])){
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$cash_goods_model = new DistributionGoods();
|
||||
|
||||
$is_fx = $total_cash = 0;
|
||||
|
||||
foreach ($order['order_goods'] as &$v){
|
||||
|
||||
$goods_info = $goods_model->dataInfo(['id'=>$v['goods_id']]);
|
||||
|
||||
if(!empty($goods_info['is_fx'])){
|
||||
|
||||
$v['fx_balance'] = $type==1?$goods_info['one_fx']:$goods_info['two_fx'];
|
||||
|
||||
$v['is_fx'] = $goods_info['is_fx'];
|
||||
|
||||
$v['fx_cash']= $v['pay_price']*$v['fx_balance']/100;
|
||||
|
||||
$total_cash += $v['fx_cash'];
|
||||
|
||||
$is_fx = 1;
|
||||
|
||||
}
|
||||
}
|
||||
//说明有分销商品
|
||||
if($is_fx==1){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'user_id' => $top_id,
|
||||
|
||||
'source_id' => $order['user_id'],
|
||||
|
||||
'order_code'=> $order['order_code'],
|
||||
|
||||
'transaction_id'=> $order['transaction_id'],
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'type' => 1,
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'fx_type' => $type,
|
||||
|
||||
'cash' => round($total_cash,2),
|
||||
|
||||
'reseller_id'=> $fx_id,
|
||||
];
|
||||
|
||||
$this->dataAdd($insert);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
foreach ($order['order_goods'] as $v){
|
||||
|
||||
if($v['is_fx']==1){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'cash_id' => $id,
|
||||
|
||||
'order_goods_id' => $v['id'],
|
||||
|
||||
'balance' => $v['fx_balance'],
|
||||
|
||||
'cash' => $v['fx_cash'] ,
|
||||
|
||||
'single_cash'=> round($v['fx_cash']/$v['goods_num'],2),
|
||||
|
||||
'num' => $v['goods_num'],
|
||||
];
|
||||
|
||||
$cash_goods_model->dataAdd($insert);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @param $type
|
||||
* @param int $status
|
||||
* @功能说明:添加土地订单分销
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 13:53
|
||||
*/
|
||||
public function addUserCashLand($fx_id,$top_id,$order,$type,$status=1){
|
||||
|
||||
$land_model = new LandList();
|
||||
|
||||
$land = $land_model->dataInfo(['id'=>$order['land_id']]);
|
||||
|
||||
if(!empty($land['is_fx'])){
|
||||
|
||||
$fx_balance = $type==1?$land['one_fx']:$land['two_fx'];
|
||||
|
||||
$total_cash = $order['pay_price']*$fx_balance/100;
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'user_id' => $top_id,
|
||||
|
||||
'source_id' => $order['user_id'],
|
||||
|
||||
'order_code'=> $order['order_code'],
|
||||
|
||||
'transaction_id'=> $order['transaction_id'],
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'type' => 2,
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'fx_type' => $type,
|
||||
|
||||
'reseller_id'=> $fx_id,
|
||||
|
||||
'cash' => round($total_cash,2),
|
||||
];
|
||||
|
||||
$this->dataAdd($insert);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'cash_id' => $id,
|
||||
|
||||
'order_goods_id' => $order['id'],
|
||||
|
||||
'balance' => $fx_balance,
|
||||
|
||||
'cash' => $total_cash ,
|
||||
|
||||
'single_cash'=> $total_cash,
|
||||
|
||||
'num' => 1,
|
||||
];
|
||||
|
||||
$cash_goods_model = new DistributionGoods();
|
||||
|
||||
$cash_goods_model->dataAdd($insert);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @param $type
|
||||
* @param int $status
|
||||
* @功能说明:添加认养订单分销
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 13:53
|
||||
*/
|
||||
public function addUserCashClaim($fx_id,$top_id,$order,$type,$status=1){
|
||||
|
||||
$land_model = new Claim();
|
||||
|
||||
$land = $land_model->dataInfo(['id'=>$order['claim_id']]);
|
||||
|
||||
if(!empty($land['is_fx'])){
|
||||
|
||||
$fx_balance = $type==1?$land['one_fx']:$land['two_fx'];
|
||||
|
||||
$total_cash = $order['pay_price']*$fx_balance/100;
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'user_id' => $top_id,
|
||||
|
||||
'source_id' => $order['user_id'],
|
||||
|
||||
'order_code'=> $order['order_code'],
|
||||
|
||||
'transaction_id'=> $order['transaction_id'],
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'type' => 3,
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'fx_type' => $type,
|
||||
|
||||
'reseller_id' => $fx_id,
|
||||
|
||||
'cash' => round($total_cash,2),
|
||||
];
|
||||
|
||||
$this->dataAdd($insert);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'cash_id' => $id,
|
||||
|
||||
'order_goods_id' => $order['id'],
|
||||
|
||||
'balance' => $fx_balance,
|
||||
|
||||
'cash' => $total_cash ,
|
||||
|
||||
'single_cash'=> round($total_cash/$order['num']),
|
||||
|
||||
'num' => $order['num'],
|
||||
];
|
||||
|
||||
$cash_goods_model = new DistributionGoods();
|
||||
|
||||
$cash_goods_model->dataAdd($insert);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 15:47
|
||||
* @功能说明:增加佣金信息
|
||||
*/
|
||||
public function addUserCash($order,$type=1){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$top_id = $user_model->where(['id'=>$order['user_id'],'is_fx'=>1])->value('pid');
|
||||
//没有上级不往下执行
|
||||
if(empty($top_id)){
|
||||
|
||||
return true;
|
||||
}
|
||||
//二级分销
|
||||
if($type==2){
|
||||
|
||||
$top_id = $user_model->where(['id'=>$top_id,'is_fx'=>1])->value('pid');
|
||||
|
||||
if(empty($top_id)){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$fx_model = new DistributionList();
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $top_id,
|
||||
|
||||
'status' => 2
|
||||
];
|
||||
//查询分销id
|
||||
$fx_id = $fx_model->where($dis)->value('id');
|
||||
|
||||
if(empty($fx_id)){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($type==1){
|
||||
//商城一级分销
|
||||
$this->addUserCashShop($fx_id,$top_id,$order,1);
|
||||
//商城二级分销
|
||||
$this->addUserCashShop($fx_id,$top_id,$order,2);
|
||||
|
||||
}elseif ($type==2){
|
||||
//土地一级分销
|
||||
$this->addUserCashLand($fx_id,$top_id,$order,1);
|
||||
//土地二级分销
|
||||
$this->addUserCashLand($fx_id,$top_id,$order,2);
|
||||
|
||||
}else{
|
||||
//土地一级分销
|
||||
$this->addUserCashClaim($fx_id,$top_id,$order,1);
|
||||
//土地二级分销
|
||||
$this->addUserCashClaim($fx_id,$top_id,$order,2);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-28 17:18
|
||||
* @功能说明:佣金到账
|
||||
*/
|
||||
public function cashArrival($order,$type=1){
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'type' => $type,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$list = $this->dataInfo($dis);
|
||||
|
||||
if(!empty($list)){
|
||||
|
||||
$res = $this->dataUpdate($dis,['status'=>2]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$cash = $list['cash'];
|
||||
|
||||
$res = $user_model->where(['id'=>$order['user_id']])->update(['fx_cash'=>Db::Raw("fx_cash+$cash")]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-29 11:49
|
||||
* @功能说明:分销佣金列表
|
||||
*/
|
||||
public function adminCashList($dis,$where,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_distribution_list b','a.reseller_id = b.id','left')
|
||||
->join('lbfarm_user_list c','a.user_id = c.id','left')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field('a.*,c.nickName,b.user_name')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
154
app/shop/model/DistributionGoods.php
Normal file
154
app/shop/model/DistributionGoods.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class DistributionGoods extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected $name = 'lbfarm_v2_distribution_goods_list';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 17:46
|
||||
* @功能说明:获取商城商品
|
||||
*/
|
||||
public function getShopGoods($cash_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.cash_id' => $cash_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_shop_order_goods b','a.order_goods_id = b.id')
|
||||
->where($dis)
|
||||
->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.singe_pay_price')
|
||||
->group('a.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 17:54
|
||||
* @功能说明:获取土地商品
|
||||
*/
|
||||
public function getLandGoods($cash_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.cash_id' => $cash_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_land_order b','a.order_goods_id = b.id')
|
||||
->where($dis)
|
||||
->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.pay_price as singe_pay_price ')
|
||||
->group('a.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-27 17:54
|
||||
* @功能说明:获取认养商品
|
||||
*/
|
||||
public function getCliamGoods($cash_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.cash_id' => $cash_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_claim_order b','a.order_goods_id = b.id')
|
||||
->where($dis)
|
||||
->field('b.goods_name,b.goods_cover,b.spe_name,b.pay_price,a.*,b.pay_price as singe_pay_price')
|
||||
->group('a.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
244
app/shop/model/DistributionList.php
Normal file
244
app/shop/model/DistributionList.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\FinanceWater;
|
||||
use app\farm\model\User;
|
||||
use think\facade\Db;
|
||||
|
||||
class DistributionList extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected $name = 'lbfarm_v2_distribution_list';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @功能说明:我的状态
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-28 10:00
|
||||
*/
|
||||
public function myTeam($user_id,$type=1){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$dis[] = ['is_fx','=',1];
|
||||
|
||||
if($type==1){
|
||||
|
||||
$dis[] = ['pid','=',$user_id];
|
||||
|
||||
}else{
|
||||
|
||||
$top_id = $user_model->where(['pid'=>$user_id,'is_fx'=>1])->column('id');
|
||||
|
||||
$dis[] = ['pid','in',$top_id];
|
||||
|
||||
}
|
||||
|
||||
$data = $user_model->where($dis)->field('id,nickName,avatarUrl,fx_bind_time')->order('fx_bind_time desc')->paginate(10)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$water_model = new FinanceWater();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['fx_bind_time'] = date('Y-m-d H:i:s',$v['fx_bind_time']);
|
||||
|
||||
$dis = [
|
||||
|
||||
'is_fx' => 1,
|
||||
|
||||
'pid' => $v['id']
|
||||
];
|
||||
//推广人数
|
||||
$v['team_count'] = $user_model->where($dis)->count();
|
||||
|
||||
$order_data = $water_model->resellerCashData($v['id']);
|
||||
|
||||
$v = array_merge($v,$order_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @param int $type
|
||||
* @功能说明:团队人数
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-28 17:58
|
||||
*/
|
||||
public function teamCount($user_id,$type=1){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$dis[] = ['is_fx','=',1];
|
||||
|
||||
if($type==1){
|
||||
|
||||
$dis[] = ['pid','=',$user_id];
|
||||
|
||||
}else{
|
||||
|
||||
$top_id = $user_model->where(['pid'=>$user_id,'is_fx'=>1])->column('id');
|
||||
|
||||
$dis[] = ['pid','in',$top_id];
|
||||
|
||||
}
|
||||
|
||||
$data = $user_model->where($dis)->count();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-12-30 11:26
|
||||
* @功能说明:后台列表
|
||||
*/
|
||||
public function adminDataList($dis,$page=10,$where=[]){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_user_list b','a.user_id = b.id','left')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field('a.*,b.nickName,b.avatarUrl')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @功能说明:用户收益列表
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-29 14:50
|
||||
*/
|
||||
public function userProfitList($dis,$page=10,$where=[]){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$data = $user_model->alias('a')
|
||||
->join('lbfarm_v2_distribution_list b','a.id = b.user_id','left')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field('b.*,a.nickName,a.avatarUrl,a.fx_cash')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @功能说明:用户收益列表
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-29 14:50
|
||||
*/
|
||||
public function userProfitSelect($dis,$where=[]){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$data = $user_model->alias('a')
|
||||
->join('lbfarm_v2_distribution_list b','a.id = b.user_id','left')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field('b.*,a.nickName,a.avatarUrl,a.fx_cash')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
103
app/shop/model/FreightConfig.php
Normal file
103
app/shop/model/FreightConfig.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class FreightConfig extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_freight_template_config';
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'province'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 17:07
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getProvinceAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$config_model = new FreightProvince();
|
||||
|
||||
$list = $config_model->where(['config_id'=>$data['id']])->column('province');
|
||||
|
||||
return array_values($list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
77
app/shop/model/FreightProvince.php
Normal file
77
app/shop/model/FreightProvince.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class FreightProvince extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_freight_template_province';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
219
app/shop/model/FreightTemplate.php
Normal file
219
app/shop/model/FreightTemplate.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class FreightTemplate extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_freight_template';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'config'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 17:07
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getConfigAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$config_model = new FreightConfig();
|
||||
|
||||
$list = $config_model->where(['template_id'=>$data['id']])->select()->toArray();
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @功能说明:添加模版
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:32
|
||||
*/
|
||||
public function tmplAdd($data){
|
||||
|
||||
if(isset($data['config'])){
|
||||
|
||||
$config = $data['config'];
|
||||
|
||||
|
||||
unset($data['config']);
|
||||
|
||||
}
|
||||
|
||||
$res = $this->dataAdd($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
if(isset($config)){
|
||||
|
||||
$this->updateSome($config,$id,$data['uniacid']);
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:37
|
||||
*/
|
||||
public function tmplUpdate($dis,$data){
|
||||
|
||||
if(isset($data['config'])){
|
||||
|
||||
$config = $data['config'];
|
||||
|
||||
unset($data['config']);
|
||||
|
||||
}
|
||||
|
||||
$res = $this->dataUpdate($dis,$data);
|
||||
|
||||
if(isset($config)){
|
||||
|
||||
$this->updateSome($config,$dis['id'],$data['uniacid']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $id
|
||||
* @param $uniacid
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-11 16:11
|
||||
*/
|
||||
public function updateSome($data,$id,$uniacid){
|
||||
|
||||
$config_model = new FreightConfig();
|
||||
|
||||
$province_model = new FreightProvince();
|
||||
|
||||
$config_model->where(['template_id'=>$id])->delete();
|
||||
|
||||
$province_model->where(['template_id'=>$id])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $key=>$value){
|
||||
|
||||
$value['uniacid'] = $uniacid;
|
||||
|
||||
$value['template_id'] = $id;
|
||||
|
||||
$province = $value['province'];
|
||||
|
||||
unset($value['province']);
|
||||
|
||||
$config_model->dataAdd($value);
|
||||
|
||||
$config_id = $config_model->getLastInsID();
|
||||
|
||||
foreach ($province as $ks=>$vs){
|
||||
|
||||
$insert[$ks] = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'config_id'=> $config_id,
|
||||
|
||||
'province' => $vs,
|
||||
|
||||
'template_id' => $id
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$province_model->saveAll($insert);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
187
app/shop/model/GoodsSpePrice.php
Normal file
187
app/shop/model/GoodsSpePrice.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class GoodsSpePrice extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_shop_spe_price';
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* 查询器
|
||||
*/
|
||||
protected $append = [
|
||||
'spe_array_text',
|
||||
'spe_name_text'
|
||||
];
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* get spename
|
||||
*/
|
||||
public function getSpeNameTextAttr($value,$data){
|
||||
$pec_id = explode('-',$data['spe_id_1']);
|
||||
$spe_names = Db::name('lbfarm_v2_shop_spe')->where(['status'=>1])->where('id','IN',$pec_id)->select()->toArray();
|
||||
if(!empty($spe_names)){
|
||||
foreach ($spe_names as $value){
|
||||
$spe_name[] = $value['title'];
|
||||
}
|
||||
return implode('-',$spe_name);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* get spearray
|
||||
*/
|
||||
public function getSpeArrayTextAttr($value,$data){
|
||||
return explode('-',$data['spe_id_1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* 获取商品多规格价格库存
|
||||
*/
|
||||
public function goodsSpePrice($dis){
|
||||
$data = $this->where($dis)->select()->toArray();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return int|string
|
||||
* 添加商品规格
|
||||
*/
|
||||
|
||||
public function goodsSpePriceAdd($data){
|
||||
$data['create_time'] = time();
|
||||
$data['status'] = 1;
|
||||
$res = $this->insert($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return int|string
|
||||
* 添加商品规格
|
||||
*/
|
||||
|
||||
public function goodsSpePriceSaveAll($data){
|
||||
$res = $this->saveAll($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return int|string
|
||||
* 编辑啊商品规格
|
||||
*/
|
||||
|
||||
public function goodsSpePriceUpdate($dis,$data){
|
||||
$data['update_time'] = time();
|
||||
$res = $this->where($dis)->update($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* 根据条件获取id
|
||||
*/
|
||||
|
||||
public function goodsSpePriceId($dis){
|
||||
$data = $this->where($dis)->column('id');
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* 获取商品多规格价格库存
|
||||
*/
|
||||
public function singeSpePrice($dis){
|
||||
$data = $this->where($dis)->find();
|
||||
return !empty($data)?$data->toArray():$data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-25 16:13
|
||||
* @功能说明:获取售罄的商品id
|
||||
*/
|
||||
public function getSellOut($uniacid,$type=0){
|
||||
|
||||
$dis[] = ['uniacid','=', $uniacid];
|
||||
|
||||
$dis[] = ['status','=', 1];
|
||||
|
||||
$all_goods = $this->where($dis)->column('goods_id');
|
||||
|
||||
$dis[] = ['stock','>',0];
|
||||
|
||||
$diff_goods = $this->where($dis)->column('goods_id');
|
||||
|
||||
if($type==1){
|
||||
|
||||
return $diff_goods;
|
||||
}
|
||||
|
||||
$data = array_diff($all_goods,$diff_goods);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-26 09:53
|
||||
* @功能说明:获取商品库存
|
||||
*/
|
||||
public function getGoodsStock($goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'goods_id' => $goods_id,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$stock = $this->where($dis)->sum('stock');
|
||||
|
||||
return is_numeric($stock)?$stock:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-01-19 18:15
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
195
app/shop/model/IntegralGoods.php
Normal file
195
app/shop/model/IntegralGoods.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class IntegralGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_integral_shop_goods';
|
||||
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'spe_name'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:54
|
||||
* @功能说明:规格名字
|
||||
*/
|
||||
public function getSpeNameAttr($value,$data){
|
||||
|
||||
if(!empty($data['spe_id'])){
|
||||
|
||||
$spe_model = new GoodsSpePrice();
|
||||
|
||||
$info = $spe_model->dataInfo(['id'=>$data['spe_id']]);
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
return $info['spe_name_text'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:34
|
||||
* @功能说明:积分列表可以通过商品名字查询
|
||||
*/
|
||||
public function dataGoodsList($dis,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_v2_shop_goods b','a.goods_id = b.id','left')
|
||||
->where($dis)
|
||||
->field('a.*,b.name as goods_name')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:54
|
||||
* @功能说明:初始化活动时间
|
||||
*/
|
||||
public function initAtv(){
|
||||
|
||||
$this->where('start_time','>',time())->update(['atv_status'=>1]);
|
||||
|
||||
$this->where('start_time','<',time())->update(['atv_status'=>2]);
|
||||
|
||||
$this->where('end_time','>',time())->update(['atv_status'=>3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 17:58
|
||||
* @功能说明:修改
|
||||
*/
|
||||
public function updateAtvStock($integral_id,$goods_id,$spe_id,$num,$type=1){
|
||||
|
||||
$dis = [
|
||||
|
||||
'atv_id' => $integral_id,
|
||||
|
||||
'goods_id'=> $goods_id,
|
||||
|
||||
'spe_id' => $spe_id
|
||||
|
||||
];
|
||||
|
||||
$integral_goods_model = new IntegralGoods();
|
||||
|
||||
$find = $integral_goods_model->dataInfo($dis);
|
||||
|
||||
if($type==1){
|
||||
|
||||
if(empty($find)){
|
||||
|
||||
return ['code'=>500,'msg'=>'积分活动已下架'];
|
||||
|
||||
}
|
||||
|
||||
if($find['have_stock']+$num>$find['stock']){
|
||||
|
||||
return ['code'=>500,'msg'=>'可兑换数量不足'];
|
||||
|
||||
}
|
||||
|
||||
$integral_goods_model->where($dis)->update(['have_stock'=> Db::Raw("have_stock+$num")]);
|
||||
|
||||
}else{
|
||||
|
||||
if(!empty($find)){
|
||||
|
||||
$integral_goods_model->where($dis)->update(['have_stock'=> Db::Raw("have_stock-$num")]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
656
app/shop/model/IntegralList.php
Normal file
656
app/shop/model/IntegralList.php
Normal file
@@ -0,0 +1,656 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\ShopGoods;
|
||||
use think\facade\Db;
|
||||
|
||||
class IntegralList extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_integral_shop';
|
||||
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'show_price',
|
||||
|
||||
'all_stock',
|
||||
|
||||
'all_have_stock',
|
||||
|
||||
'goods_info',
|
||||
|
||||
'store_info'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:获取门店信息
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-13 18:38
|
||||
*/
|
||||
public function getStoreInfoAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$store_model = new IntegralStore();
|
||||
$dis = [
|
||||
|
||||
'a.integral_id' => $data['id'],
|
||||
|
||||
'b.status' => 2,
|
||||
|
||||
'b.type' => 2
|
||||
];
|
||||
|
||||
$list = $store_model->alias('a')
|
||||
->join('lbfarm_farmer b','a.store_id = b.id')
|
||||
->where($dis)
|
||||
->field('a.*,b.title,b.is_admin,b.cover')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return array_values($list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:52
|
||||
* @功能说明:参与活动的商品规格信息
|
||||
*/
|
||||
public function getGoodsInfoAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new IntegralGoods();
|
||||
|
||||
$list = $i_model->alias('a')
|
||||
->join('lbfarm_v2_shop_spe_price b','a.spe_id = b.id')
|
||||
->where(['a.atv_id' => $data['id']])
|
||||
->field(['b.stock as goods_stock','b.price as goods_price','a.*'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:46
|
||||
* @功能说明:获取第一个规格的价格
|
||||
*/
|
||||
public function getShowPriceAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new IntegralGoods();
|
||||
|
||||
$info = $i_model->dataInfo(['atv_id'=>$data['id']]);
|
||||
|
||||
$text = '';
|
||||
|
||||
if(!empty($info['integral'])){
|
||||
|
||||
$text .= $info['integral'].'积分';
|
||||
}
|
||||
|
||||
if(!empty($info['price'])){
|
||||
|
||||
$text .= '+'.$info['price'].'元';
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:50
|
||||
* @功能说明:总的库存
|
||||
*/
|
||||
public function getAllStockAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new IntegralGoods();
|
||||
|
||||
$num = $i_model->where(['atv_id'=>$data['id']])->sum('stock');
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:50
|
||||
* @功能说明:总的库存
|
||||
*/
|
||||
public function getAllHaveStockAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new IntegralGoods();
|
||||
|
||||
$num = $i_model->where(['atv_id'=>$data['id']])->sum('have_stock');
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$goods_info = $data['goods_info'];
|
||||
|
||||
unset($data['goods_info']);
|
||||
|
||||
// $store_info = $data['store_info'];
|
||||
//
|
||||
// unset($data['store_info']);
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
$res = $this->updateSome($id,$data,$goods_info);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:21
|
||||
* @功能说明:
|
||||
*/
|
||||
public function updateSome($id,$data,$goods_info){
|
||||
|
||||
$i_model = new IntegralGoods();
|
||||
|
||||
$atv = $this->dataInfo(['id'=>$id]);
|
||||
|
||||
$arr = [];
|
||||
|
||||
if(!empty($goods_info)){
|
||||
|
||||
foreach ($goods_info as &$value){
|
||||
|
||||
$i_dis = [
|
||||
|
||||
'atv_id' => $id,
|
||||
|
||||
'goods_id'=> $data['goods_id'],
|
||||
|
||||
'spe_id' => $value['spe_id'],
|
||||
];
|
||||
|
||||
$have_stock = $i_model->where($i_dis)->value('have_stock');
|
||||
|
||||
$i_model->where($i_dis)->delete();
|
||||
|
||||
$where = [];
|
||||
|
||||
$where[] = ['a.goods_id','=',$data['goods_id']];
|
||||
|
||||
$where[] = ['b.spe_id','=',$value['spe_id']];
|
||||
|
||||
$where[] = ['a.status','>',-1];
|
||||
|
||||
$where[] = ['a.id','<>',$id];
|
||||
|
||||
$info = $i_model->alias('b')
|
||||
->join('lbfarm_v2_integral_shop a','a.id = b.atv_id')
|
||||
->where($where)
|
||||
->field('a.*,b.*')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
foreach ($info as $vs){
|
||||
|
||||
$res = is_time_cross($vs['start_time'],$vs['end_time'],$atv['start_time'],$atv['end_time']);
|
||||
|
||||
if($res==false){
|
||||
|
||||
return ['code'=>500,'msg'=>'规格'.$vs['spe_name'].'该时间段已有积分活动,请先删除,再添加'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $data['uniacid'],
|
||||
|
||||
'goods_id'=> $data['goods_id'],
|
||||
|
||||
'spe_id' => $value['spe_id'],
|
||||
|
||||
'stock' => $value['stock'],
|
||||
|
||||
'price' => $value['price'],
|
||||
|
||||
'integral'=> $value['integral'],
|
||||
|
||||
'have_stock'=> !empty($have_stock)?$have_stock:0,
|
||||
|
||||
'atv_id' => $id,
|
||||
];
|
||||
|
||||
$i_model->dataAdd($insert);
|
||||
|
||||
$arr[] = $i_model->getLastInsID();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$i_model->where('id','not in',$arr)->where('atv_id','=',$id)->delete();
|
||||
|
||||
// $store_model = new IntegralStore();
|
||||
//
|
||||
// $store_model->where(['integral_id'=>$id])->delete();
|
||||
//
|
||||
// foreach ($store_info as $k=>$v){
|
||||
//
|
||||
// $store_insert[$k] = [
|
||||
//
|
||||
// 'uniacid' => $data['uniacid'],
|
||||
//
|
||||
// 'integral_id' => $id,
|
||||
//
|
||||
// 'store_id' => $v
|
||||
//
|
||||
// ];
|
||||
//
|
||||
// }
|
||||
//
|
||||
// $store_model->saveAll($store_insert);
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
if(!empty($data['goods_info'])){
|
||||
|
||||
$goods_info = $data['goods_info'];
|
||||
|
||||
unset($data['goods_info']);
|
||||
}
|
||||
|
||||
// if(!empty($data['store_info'])){
|
||||
//
|
||||
// $store_info = $data['store_info'];
|
||||
//
|
||||
// unset($data['store_info']);
|
||||
// }
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(!empty($goods_info)){
|
||||
|
||||
$res = $this->updateSome($dis['id'],$data,$goods_info);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:34
|
||||
* @功能说明:积分列表可以通过商品名字查询
|
||||
*/
|
||||
public function dataGoodsList($dis,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_shop_goods b','a.goods_id = b.id','left')
|
||||
->where($dis)
|
||||
->field('a.*,b.goods_name,cover')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:54
|
||||
* @功能说明:初始化活动时间
|
||||
*/
|
||||
public function initAtv(){
|
||||
|
||||
$this->where('start_time','>',time())->update(['atv_status'=>1]);
|
||||
|
||||
$this->where('start_time','<',time())->update(['atv_status'=>2]);
|
||||
|
||||
$this->where('end_time','<',time())->update(['atv_status'=>3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-01 10:18
|
||||
* @功能说明:正在进行中的活动
|
||||
*/
|
||||
public function atvIng($goods_id,$spe_id=0){
|
||||
|
||||
$dis[] = ['a.atv_status','=',2];
|
||||
|
||||
$dis[] = ['a.goods_id','=',$goods_id];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
if(!empty($spe_id)){
|
||||
|
||||
$dis[] = ['b.spe_id','=',$spe_id];
|
||||
}
|
||||
|
||||
// if(!empty($store_id)){
|
||||
//
|
||||
// $dis[] = ['c.store_id','=',$store_id];
|
||||
//
|
||||
// }
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_integral_shop_goods b','a.id = b.atv_id')
|
||||
// ->join('lbfarm_v2_integral_store c','a.id = c.integral_id')
|
||||
->where($dis)
|
||||
->field('a.*,b.*')
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-01 10:18
|
||||
* @功能说明:正在进行中的活动
|
||||
*/
|
||||
public function buyLimit($goods_id,$spe_id=0){
|
||||
|
||||
$dis[] = ['a.atv_status','=',2];
|
||||
|
||||
$dis[] = ['a.goods_id','=',$goods_id];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
if(!empty($spe_id)){
|
||||
|
||||
$dis[] = ['b.spe_id','=',$spe_id];
|
||||
}
|
||||
|
||||
// if(!empty($store_id)){
|
||||
//
|
||||
// $dis[] = ['c.store_id','=',$store_id];
|
||||
//
|
||||
// }
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_integral_shop_goods b','a.id = b.atv_id')
|
||||
// ->join('lbfarm_v2_integral_store c','a.id = c.integral_id')
|
||||
->where($dis)
|
||||
->field('a.*')
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 14:41
|
||||
* @功能说明:获取是否
|
||||
*/
|
||||
public function getBuyLimit($list){
|
||||
|
||||
$this->initAtv();
|
||||
|
||||
$data['buy_limit'] = 1;
|
||||
|
||||
$data['discount_add'] = 1;
|
||||
|
||||
foreach ($list as $value){
|
||||
|
||||
$res = $this->buyLimit($value['goods_id'],$value['spe_id']);
|
||||
|
||||
if(!empty($res)){
|
||||
|
||||
if($res['buy_limit']==0){
|
||||
|
||||
$data['buy_limit'] = 0;
|
||||
}
|
||||
|
||||
if($res['discount_add']==0){
|
||||
|
||||
$data['discount_add'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-11 16:50
|
||||
* @功能说明:获取活动次数
|
||||
*/
|
||||
public function getAtvNum1($id,$user_id){
|
||||
|
||||
$order_model = new Order();
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.integral_id' => $id,
|
||||
|
||||
'a.user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$num = $order_model->alias('a')
|
||||
->join('longbing_card_v2_shop_order_goods b','a.id = b.order_id')
|
||||
->where('a.pay_type','>=',1)
|
||||
->where($dis)
|
||||
->sum('goods_num');
|
||||
|
||||
return $num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @return float
|
||||
* 获取历史商品件数
|
||||
*/
|
||||
public function getAtvNum($id,$user_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.integral_id' => $id,
|
||||
|
||||
'b.user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$order_model = new \app\farm\model\ShopOrderGoods();
|
||||
|
||||
//取消订单的不算 chen
|
||||
$num = $order_model->alias('a')
|
||||
->join('lbfarm_shop_order b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->group('a.id')
|
||||
->sum('a.goods_num');
|
||||
|
||||
|
||||
$order_id = $order_model->alias('a')
|
||||
->join('lbfarm_shop_order b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->column('b.id');
|
||||
|
||||
$order_refund_goods = new \app\farm\model\ShopRefundGoods();
|
||||
//申请退款成功的
|
||||
$refund_num = $order_refund_goods->where('order_id','in',$order_id)->where(['status'=>2])->sum('goods_num');
|
||||
|
||||
return $num - $refund_num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 11:01
|
||||
* @功能说明:积分商品列表
|
||||
*/
|
||||
public function integralGoodsList($dis,$page=10){
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$i_goods_model = new IntegralGoods();
|
||||
|
||||
$spe_model = new GoodsSpePrice();
|
||||
|
||||
$data = $goods_model->alias('a')
|
||||
->join('lbfarm_v2_integral_shop_goods b','b.goods_id = a.id')
|
||||
->join('lbfarm_v2_integral_shop c','b.atv_id = c.id')
|
||||
->where($dis)
|
||||
->field('a.goods_name,a.cover,a.id as goods_id,c.id as atv_id,c.type')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$spe = $i_goods_model->where(['atv_id'=>$v['atv_id']])->order('price')->find()->toArray();
|
||||
|
||||
$v['integral'] = $spe['integral'];
|
||||
|
||||
$v['price'] = $spe['price'];
|
||||
|
||||
$v['init_price'] = $spe_model->where(['id'=>$spe['spe_id']])->sum('price');
|
||||
|
||||
$v['all_have_stock'] = $i_goods_model->where(['atv_id'=>$v['atv_id']])->sum('have_stock');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
512
app/shop/model/IntegralLog.php
Normal file
512
app/shop/model/IntegralLog.php
Normal file
@@ -0,0 +1,512 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\massage\model\User;
|
||||
use longbingcore\wxcore\PushMsgModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class IntegralLog extends BaseModel
|
||||
{
|
||||
//会员积分表
|
||||
protected $name = 'lbfarm_v2_integral_log';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'create_time_text'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 13:57
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getCreateTimeTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['create_time'])){
|
||||
|
||||
return date('Y-m-d H:i:s',$data['create_time']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function integralAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 16:35
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function integralList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order(['update_time desc','id desc'])->paginate($page)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
if($v['controller_type']==0){
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$icon = $v['integral_add']>0?'+':'-';
|
||||
|
||||
$integral_add = $v['integral_add']>0?$v['integral_add']:$v['integral_add']*-1;
|
||||
|
||||
$text = $v['integral_add']>0?'增加积分':'使用积分';
|
||||
|
||||
$boj = $this->returnObj($v['type']);
|
||||
|
||||
$refund = $v['refund']==1?'(已退款)':'';
|
||||
|
||||
$v['text'] = $boj.$text.$icon.$integral_add.',现积分 '.$v['integral_after'].$refund;
|
||||
|
||||
$v['type_text'] = $boj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 15:17
|
||||
* @功能说明:返回一个对象
|
||||
*/
|
||||
public function returnObj($type){
|
||||
|
||||
switch ($type){
|
||||
|
||||
//加
|
||||
case 1:
|
||||
return '购买商城商品';
|
||||
|
||||
break;
|
||||
//购买储值套餐赠送
|
||||
case 2:
|
||||
return '购买储值套餐';
|
||||
|
||||
break;
|
||||
|
||||
case 3://减
|
||||
return '购买商城商品';
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
return '购买土地产品';
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
return '购买认养产品';
|
||||
|
||||
break;
|
||||
case 6://售后
|
||||
return '商城商品退款';
|
||||
|
||||
break;
|
||||
case 7://售后
|
||||
return '购买养殖产品';
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
return '购买认养配送';
|
||||
|
||||
break;
|
||||
|
||||
case 9:
|
||||
return '购买土地配送';
|
||||
|
||||
break;
|
||||
|
||||
case 10:
|
||||
return '签到';
|
||||
|
||||
break;
|
||||
case 11://消耗
|
||||
return '抽奖';
|
||||
|
||||
break;
|
||||
case 12:
|
||||
return '后台充值';
|
||||
|
||||
break;
|
||||
case 13:
|
||||
return '后台扣除';
|
||||
|
||||
break;
|
||||
|
||||
case 14:
|
||||
return '抽奖获取';
|
||||
|
||||
break;
|
||||
default:
|
||||
return '消费';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function integralInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function integralUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-24 10:49
|
||||
* @功能说明:发送积分消息
|
||||
*/
|
||||
public function sendMsg($data,$user_id,$integral,$type){
|
||||
|
||||
if(in_array($type,[1,3,4,5,10,11])){
|
||||
|
||||
$data['integral'] = abs($integral);
|
||||
|
||||
$data['user_id'] = $user_id;
|
||||
//消费获取的积分
|
||||
if(in_array($type,[1,2,4,5])){
|
||||
|
||||
$s_type = 10;
|
||||
|
||||
}elseif (in_array($type,[3])){
|
||||
//消费消耗的积分
|
||||
$s_type = 11;
|
||||
|
||||
}elseif (in_array($type,[11])){
|
||||
//抽奖消耗
|
||||
$s_type = 12;
|
||||
|
||||
}elseif (in_array($type,[10])){
|
||||
//签到获取积分
|
||||
$s_type = 13;
|
||||
|
||||
}
|
||||
|
||||
$info_model = new PushMsgModel($data['uniacid']);
|
||||
|
||||
$info_model->sendMsg($data,$s_type);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 10:28
|
||||
* @功能说明:增加用户积分
|
||||
*/
|
||||
public function integralUserAdd($user_id,$integral,$uniacid,$status = 2,$type=0,$order_id=0,$time=0,$data=[]){
|
||||
|
||||
// if(!in_array($type,[5,6,7,8])){
|
||||
// //积分倍率
|
||||
// $arr = $this->pointDouble($user_id,$integral);
|
||||
//
|
||||
// $integral = $arr['integral'];
|
||||
// //查询单日获取积分是否超限
|
||||
// $integral = $this->dayGetIntegral($user_id,$integral,$uniacid);
|
||||
// }
|
||||
|
||||
$time = !empty($time)?$time:time();
|
||||
|
||||
if(!empty($integral)&&$integral!='0.00'){
|
||||
//发送消息
|
||||
$this->sendMsg($data,$user_id,$integral,$type);
|
||||
|
||||
$member_model = new \app\farm\model\User();
|
||||
|
||||
$member_info = $member_model->dataInfo(['id'=>$user_id]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'integral_add' => $integral,
|
||||
|
||||
'integral_before'=> $member_info['integral'],
|
||||
|
||||
'integral_after' => $member_info['integral']+$integral,
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'type' => $type,
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'double' => !empty($arr['double'])?$arr['double']:1,
|
||||
|
||||
'create_time' => $time,
|
||||
|
||||
'update_time' => $time,
|
||||
];
|
||||
|
||||
$res = $this->insert($insert);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $member_model->dataUpdate(['id'=>$user_id],['integral'=>$insert['integral_after']]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**\
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-12 17:31
|
||||
* @功能说明:积分倍率
|
||||
*/
|
||||
public function pointDouble($user_id,$integral){
|
||||
|
||||
$arr['double'] = 1;
|
||||
|
||||
$arr['integral'] = $integral;
|
||||
|
||||
if($integral<0){
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$member_level = $user_model->where(['id'=>$user_id])->value('member_level');
|
||||
|
||||
|
||||
if(empty($member_level)){
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$level = $level_model->levelInfo(['id'=>$member_level]);
|
||||
|
||||
if(empty($level)){
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
if(empty($level['integral_switch'])){
|
||||
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
$arr['double'] = $level['integral'];
|
||||
|
||||
$arr['integral'] = floor($level['integral']*$integral);
|
||||
|
||||
return $arr;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-12 14:05
|
||||
* @功能说明:单天获得积分
|
||||
*/
|
||||
public function dayGetIntegral($user_id,$integral,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
if($config['integral_limit']==0){
|
||||
|
||||
return $integral;
|
||||
}
|
||||
|
||||
$dis[] = ['user_id','=',$user_id];
|
||||
|
||||
$dis[] = ['integral_add','>',0];
|
||||
|
||||
$dis[] = ['type','not in',[5,6,7]];
|
||||
//单日获取积分
|
||||
$integral_day = $this->where($dis)->whereDay('create_time')->sum('integral_add');
|
||||
//单日可获取最大积分
|
||||
$integral_day_max = $config['integral_day_max'];
|
||||
|
||||
$point = $integral_day_max-$integral_day;
|
||||
|
||||
if($point<=0){
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$point = $point-$integral>0?$integral:$point;
|
||||
|
||||
return $point;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 10:21
|
||||
* @功能说明:每日领取的积分
|
||||
*/
|
||||
public function dayIntegral($user_id,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
if($config['integral_limit']==1){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'refund' => 0,
|
||||
|
||||
'type' => 1
|
||||
];
|
||||
|
||||
$integral = $this->where($dis)->where('status','>',0)->whereDay('create_time')->sum('integral_add');
|
||||
|
||||
$re_integral = $config['integral_day_max'] - $integral;
|
||||
|
||||
$re_integral = $re_integral>0?$re_integral:0;
|
||||
|
||||
return intval($re_integral);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 11:07
|
||||
* @功能说明:给用户加积分
|
||||
*/
|
||||
public function incUserIntegral($order_id,$user_id,$uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$info = $this->where($dis)->select()->toArray();
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
foreach ($info as $value){
|
||||
|
||||
$integral = $value['integral_add'];
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$update = [
|
||||
//修改状态
|
||||
'status' => 2,
|
||||
//当前
|
||||
'integral_before' => intval($member_info['integral']),
|
||||
//修改后对
|
||||
'integral_after' => intval($member_info['integral']+$integral),
|
||||
|
||||
];
|
||||
|
||||
$this->integralUpdate(['id'=>$value['id']],$update);
|
||||
|
||||
if(is_numeric($integral)&&$integral>0){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$member_model->incDecGrowth($dis,$integral,'integral');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
78
app/shop/model/IntegralStore.php
Normal file
78
app/shop/model/IntegralStore.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class IntegralStore extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_integral_store';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
183
app/shop/model/LuckConfig.php
Normal file
183
app/shop/model/LuckConfig.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\Coupon;
|
||||
use think\facade\Db;
|
||||
|
||||
class LuckConfig extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_luck_config';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
|
||||
'coupon_title'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 18:03
|
||||
*/
|
||||
public function getCouponTitleAttr($value,$data){
|
||||
|
||||
if(isset($data['coupon_id'])){
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$title = $coupon_model->where(['id'=>$data['coupon_id']])->value('title');
|
||||
|
||||
return $title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
if(isset($data['data'])){
|
||||
|
||||
$arr = $data['data'];
|
||||
|
||||
unset($data['data']);
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
if(isset($arr)){
|
||||
|
||||
$this->updateSome($id,$arr,$data['uniacid']);
|
||||
|
||||
}
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:24
|
||||
* @功能说明:添加奖品信息
|
||||
*/
|
||||
public function updateSome($id,$data,$uniacid){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$arr = [];
|
||||
|
||||
// $config_model->where(['luck_id'=>$id])->delete();
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$v['uniacid'] = $uniacid;
|
||||
|
||||
$v['luck_id'] = $id;
|
||||
|
||||
if(empty($v['id'])){
|
||||
|
||||
$config_model->insert($v);
|
||||
|
||||
$arr[] = $v['id'];
|
||||
|
||||
}else{
|
||||
|
||||
$config_model->dataUpdate(['id'=>$v['id']],$v);
|
||||
|
||||
$arr[] = $config_model->getLastInsID();
|
||||
|
||||
}
|
||||
|
||||
$config_model->save($v);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$config_model->where(['luck_id'=>$id])->where('id','not in',$arr)->delete();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
if(isset($data['data'])){
|
||||
|
||||
$arr = $data['data'];
|
||||
|
||||
unset($data['data']);
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(isset($arr)){
|
||||
|
||||
$this->updateSome($dis['id'],$arr,$data['uniacid']);
|
||||
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
463
app/shop/model/LuckDraw.php
Normal file
463
app/shop/model/LuckDraw.php
Normal file
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\Coupon;
|
||||
use function GuzzleHttp\Promise\is_settled;
|
||||
use think\facade\Db;
|
||||
|
||||
class LuckDraw extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_luck_draw';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'data'
|
||||
|
||||
];
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:35
|
||||
*/
|
||||
public function getDataAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$list = $config_model->where(['luck_id'=>$data['id'],'is_luck'=>1])->order('top,id desc')->select()->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
if(isset($data['data'])){
|
||||
|
||||
$arr = $data['data'];
|
||||
|
||||
unset($data['data']);
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
if(isset($arr)){
|
||||
|
||||
$this->updateSome($id,$arr,$data['uniacid']);
|
||||
|
||||
}
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:24
|
||||
* @功能说明:添加奖品信息
|
||||
*/
|
||||
public function updateSome($id,$data,$uniacid){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$list = $this->changeData($data,$uniacid,$id);
|
||||
|
||||
$data = array_merge($data,$list);
|
||||
|
||||
$ids = array_column($data,'id');
|
||||
|
||||
$config_model->where(['luck_id'=>$id])->where('id','not in',$ids)->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$v['uniacid'] = $uniacid;
|
||||
|
||||
$v['luck_id'] = $id;
|
||||
|
||||
if(!empty($v['id'])){
|
||||
|
||||
$config_model->dataUpdate(['id'=>$v['id']],$v);
|
||||
|
||||
}else{
|
||||
|
||||
$config_model->insert($v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 14:50
|
||||
* @功能说明:
|
||||
*/
|
||||
public function changeData($data,$uniacid,$id){
|
||||
|
||||
$blance = array_sum(array_column($data,'balance'));
|
||||
|
||||
$no_balance = 100-$blance;
|
||||
|
||||
$no_balance = $no_balance>0?ceil($no_balance/count($data)):0;
|
||||
|
||||
for ($i=1;$i<=9;$i++){
|
||||
|
||||
if(!in_array($i,array_column($data,'top'))){
|
||||
|
||||
$arr[] = $i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($arr)){
|
||||
|
||||
foreach ($arr as $key=> $value){
|
||||
|
||||
$list[$key] = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'top' => $value,
|
||||
|
||||
'title' => '谢谢参与',
|
||||
|
||||
'is_luck' => 0,
|
||||
|
||||
'balance' => $no_balance,
|
||||
|
||||
'luck_id' => $id,
|
||||
|
||||
'num' => 1
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return !empty($list)?$list:[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
if(isset($data['data'])){
|
||||
|
||||
$arr = $data['data'];
|
||||
|
||||
unset($data['data']);
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(isset($arr)){
|
||||
|
||||
$this->updateSome($dis['id'],$arr,$data['uniacid']);
|
||||
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $arr
|
||||
* @功能说明:抽奖算法
|
||||
* 根据概率随机中奖
|
||||
*
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 14:40
|
||||
*/
|
||||
public function getRand($data){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$arr[$v['id']] = $v['balance'];
|
||||
}
|
||||
|
||||
$sum = array_sum($arr);
|
||||
|
||||
$res = 0;
|
||||
|
||||
foreach ($arr as $key=>$value){
|
||||
|
||||
$rand_num = mt_rand(1,$sum);
|
||||
|
||||
if($rand_num<=$value){
|
||||
|
||||
$res = $key;
|
||||
|
||||
break;
|
||||
}else{
|
||||
|
||||
$sum -= $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:54
|
||||
* @功能说明:初始化活动时间
|
||||
*/
|
||||
public function initAtv(){
|
||||
|
||||
$this->where('start_time','>',time())->update(['atv_status'=>1]);
|
||||
|
||||
$this->where('start_time','<',time())->update(['atv_status'=>2]);
|
||||
|
||||
$this->where('end_time','<',time())->update(['atv_status'=>3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 15:04
|
||||
* @功能说明:用户抽奖
|
||||
*/
|
||||
public function luckDraw($atv_id,$user_id,$use_integral,$user_num=0){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
//获取未中奖的奖项
|
||||
$list = $config_model->where(['luck_id'=>$atv_id])->where('num','>',0)->order('top,id desc')->select()->toArray();
|
||||
|
||||
if(empty($list)){
|
||||
|
||||
return ['code'=>500,'msg'=>'所有奖已被抽完'];
|
||||
}
|
||||
|
||||
$id = $this->getRand($list);
|
||||
|
||||
$data = $config_model->dataInfo(['id'=>$id]);
|
||||
|
||||
$data['times'] = $user_num+1;
|
||||
|
||||
if(empty($data)||($data['is_luck']==1&&$data['num']<=0)){
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
//如果中奖需减数量
|
||||
if($data['is_luck']==1){
|
||||
|
||||
$res = $config_model->dataUpdate(['id'=>$id,'num'=>$data['num']],['num'=>$data['num']-1]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
}
|
||||
//添加中奖记录
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $data['uniacid'],
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'atv_id' => $atv_id,
|
||||
|
||||
'type' => $data['type'],
|
||||
|
||||
'coupon_id' => $data['coupon_id'],
|
||||
|
||||
'integral' => $data['integral'],
|
||||
|
||||
'icon' => $data['icon'],
|
||||
|
||||
'title' => $data['title'],
|
||||
|
||||
'is_luck' => $data['is_luck'],
|
||||
|
||||
'use_integral' => $use_integral,
|
||||
|
||||
];
|
||||
|
||||
$record_model = new LuckRecord();
|
||||
|
||||
$i_model = new IntegralLog();
|
||||
|
||||
$res = $record_model->dataAdd($insert);
|
||||
|
||||
if($res==0){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
|
||||
}
|
||||
$record_id = $record_model->getLastInsID();
|
||||
|
||||
if($data['is_luck']==1){
|
||||
//卡券
|
||||
if($data['type']==1){
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$coupon = $coupon_model->dataInfo(['id'=>$data['coupon_id'],'status'=>1]);
|
||||
|
||||
if(empty($coupon)){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
|
||||
$coupon_model = new \app\farm\model\CouponRecord();
|
||||
|
||||
$res = $coupon_model->recordAdd($data['coupon_id'],$user_id);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
|
||||
}else{
|
||||
//积分
|
||||
$res = $i_model->integralUserAdd($user_id,$data['integral'],$data['uniacid'],2,14,$record_id,0,$data);
|
||||
|
||||
if($res==false){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
}
|
||||
}
|
||||
//积分
|
||||
$res = $i_model->integralUserAdd($user_id,$use_integral*-1,$data['uniacid'],2,11,$record_id,0,$data);
|
||||
|
||||
if($res==false){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->luckDraw($atv_id,$user_id,$use_integral);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
* @功能说明:校验时间 统一时间段只能有一个活动
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-26 13:46
|
||||
*/
|
||||
public function checkTime($input){
|
||||
|
||||
if(!empty($input['start_time'])){
|
||||
|
||||
$dis[] = ['uniacid','=',$input['uniacid']];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['id'])){
|
||||
|
||||
$dis[] = ['id','<>',$input['id']];
|
||||
}
|
||||
|
||||
$data = $this->where($dis)->select()->toArray();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $value){
|
||||
|
||||
$res = is_time_cross($input['start_time'],$input['end_time'],$value['start_time'],$value['end_time']);
|
||||
|
||||
if($res==false){
|
||||
|
||||
return ['code'=>500,'msg'=>'该时间段已经有该活动,活动名称:'.$value['title']];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
152
app/shop/model/LuckRecord.php
Normal file
152
app/shop/model/LuckRecord.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\Coupon;
|
||||
use think\facade\Db;
|
||||
|
||||
class LuckRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_luck_record';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 18:03
|
||||
*/
|
||||
public function getCouponTitleAttr($value,$data){
|
||||
|
||||
if(isset($data['coupon_id'])){
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$title = $coupon_model->where(['id'=>$data['coupon_id']])->value('title');
|
||||
|
||||
return $title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 14:24
|
||||
* @功能说明:添加奖品信息
|
||||
*/
|
||||
public function updateSome($id,$data,$uniacid){
|
||||
|
||||
$config_model = new LuckConfig();
|
||||
|
||||
$config_model->where(['luck_id'=>$id])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$v['uniacid'] = $uniacid;
|
||||
|
||||
$v['luck_id'] = $id;
|
||||
|
||||
$config_model->insert($v);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-26 16:14
|
||||
* @功能说明:中奖记录
|
||||
*/
|
||||
public function recordList($dis,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_user_list b','a.user_id = b.id','left')
|
||||
->where($dis)
|
||||
->field('a.*,b.nickName,b.avatarurl')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
81
app/shop/model/Member.php
Normal file
81
app/shop/model/Member.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Member extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
//1商品 2商品分类 3土地分类 4 认养分类 5养殖管理
|
||||
protected $name = 'lbfarm_v2_member';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
108
app/shop/model/SeckillConfig.php
Normal file
108
app/shop/model/SeckillConfig.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class SeckillConfig extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_seckill_config';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'spe_name'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:54
|
||||
* @功能说明:规格名字
|
||||
*/
|
||||
public function getSpeNameAttr($value,$data){
|
||||
|
||||
if(!empty($data['spe_id'])){
|
||||
|
||||
$spe_model = new GoodsSpePrice();
|
||||
|
||||
$info = $spe_model->dataInfo(['id'=>$data['spe_id']]);
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
return $info['spe_name_text'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
321
app/shop/model/SeckillGoods.php
Normal file
321
app/shop/model/SeckillGoods.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\ShopGoods;
|
||||
use think\facade\Db;
|
||||
|
||||
class SeckillGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_seckill_goods';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'show_data',
|
||||
|
||||
'goods_info',
|
||||
|
||||
'all_stock',
|
||||
|
||||
'all_have_stock',
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:50
|
||||
* @功能说明:总的库存
|
||||
*/
|
||||
public function getAllStockAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new SeckillConfig();
|
||||
|
||||
$num = $i_model->where(['atv_id'=>$data['id']])->sum('stock');
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 18:50
|
||||
* @功能说明:总的库存
|
||||
*/
|
||||
public function getAllHaveStockAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$i_model = new SeckillConfig();
|
||||
|
||||
$num = $i_model->where(['atv_id'=>$data['id']])->sum('have_stock');
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 18:29
|
||||
*/
|
||||
public function getGoodsInfoAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$config_model = new SeckillConfig();
|
||||
|
||||
$list = $config_model->alias('a')
|
||||
->join('lbfarm_v2_shop_spe_price b','a.spe_id = b.id')
|
||||
->where(['a.atv_id' => $data['id']])
|
||||
->field(['b.stock as goods_stock','b.price as goods_price','a.*'])
|
||||
->select()
|
||||
->toArray();
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-21 14:19
|
||||
*/
|
||||
public function getShowDataAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$config_model = new SeckillConfig();
|
||||
|
||||
$spe_model = new GoodsSpePrice();
|
||||
|
||||
$info = $config_model->where(['atv_id'=>$data['id']])->order('price')->find();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
$info = $info->toArray();
|
||||
|
||||
$info['init_price'] = $spe_model->where(['id'=>$info['spe_id']])->value('price');
|
||||
|
||||
}
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @功能说明:商品列表
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 14:59
|
||||
*/
|
||||
public function goodsList($dis,$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_shop_goods b','a.goods_id = b.id')
|
||||
->join('lbfarm_v2_goods_store c','c.goods_id = b.id AND c.type=1')
|
||||
->join('lbfarm_farmer d','c.store_id = d.id')
|
||||
->join('lbfarm_v2_seckill_list e','a.atv_id = e.id')
|
||||
->where($dis)
|
||||
->field('a.*,b.goods_name,b.cover,d.title as store_name,d.id as store_id,d.cover as store_cover')
|
||||
->group('a.id')
|
||||
->order('b.top desc,a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 17:19
|
||||
* @功能说明:增加销量
|
||||
*/
|
||||
public function delAtvStock($atv_id,$goods_id,$spe_id,$num){
|
||||
|
||||
$config_model = new SeckillConfig();
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.atv_id' => $atv_id,
|
||||
|
||||
'a.goods_id'=> $goods_id,
|
||||
|
||||
'b.spe_id' => $spe_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_seckill_config b','a.id = b.atv_id')
|
||||
->where($dis)
|
||||
->field('b.*')
|
||||
->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
return ['code'=>500,'msg'=>'该活动已经下架'];
|
||||
}
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
if($data['have_stock']+$num>$data['stock']){
|
||||
|
||||
return ['code'=>500,'msg'=>'可兑换数量不足'];
|
||||
|
||||
}
|
||||
|
||||
$res = $config_model->where(['id'=>$data['id']])->update(['have_stock'=> Db::Raw("have_stock+$num")]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 17:19
|
||||
* @功能说明:减少销量
|
||||
*/
|
||||
public function incAtvStock($atv_id,$goods_id,$spe_id,$num){
|
||||
|
||||
$config_model = new SeckillConfig();
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.atv_id' => $atv_id,
|
||||
|
||||
'a.goods_id'=> $goods_id,
|
||||
|
||||
'b.spe_id' => $spe_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_seckill_config b','a.id = b.atv_id')
|
||||
->where($dis)
|
||||
->field('b.*')
|
||||
->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
$res = $config_model->where(['id'=>$data['id']])->update(['have_stock'=> Db::Raw("have_stock-$num")]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $atv_id
|
||||
* @param $goods_id
|
||||
* @param $spe_id
|
||||
* @param $num
|
||||
* @param int $type
|
||||
* @功能说明:修改活动销量
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 17:47
|
||||
*/
|
||||
public function updateAtvStock($atv_id,$goods_id,$spe_id,$num,$type=1){
|
||||
|
||||
if($type==1){
|
||||
|
||||
$res = $this->delAtvStock($atv_id,$goods_id,$spe_id,$num);
|
||||
|
||||
}else{
|
||||
|
||||
$res = $this->incAtvStock($atv_id,$goods_id,$spe_id,$num);
|
||||
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
125
app/shop/model/SeckillInfo.php
Normal file
125
app/shop/model/SeckillInfo.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use longbingcore\wxcore\PushMsgModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class SeckillInfo extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_seckill_info';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-24 13:52
|
||||
* @功能说明:发送秒杀提醒
|
||||
*/
|
||||
public function sendMsg($uniacid){
|
||||
|
||||
$dis[] = ['a.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
$dis[] = ['b.status','=',1];
|
||||
|
||||
$dis[] = ['b.atv_status','=',1];
|
||||
|
||||
$dis[] = ['b.start_time','<',time()+120];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_seckill_list b','a.kill_id = b.id')
|
||||
->join('lbfarm_v2_seckill_goods c','c.atv_id = b.id')
|
||||
->where($dis)
|
||||
->field('a.*')
|
||||
->group('a.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
$push_model = new PushMsgModel($uniacid);
|
||||
|
||||
foreach ($data as $v){
|
||||
|
||||
$this->dataUpdate(['id'=>$v['id']],['status'=>2]);
|
||||
|
||||
$v['id'] = $v['goods_id'];
|
||||
|
||||
$push_model->sendMsg($v,15);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
374
app/shop/model/SeckillList.php
Normal file
374
app/shop/model/SeckillList.php
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\ShopGoods;
|
||||
use think\facade\Db;
|
||||
|
||||
class SeckillList extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_seckill_list';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 15:43
|
||||
* @功能说明:检查活动时间
|
||||
*/
|
||||
public function atvCheck($input){
|
||||
|
||||
$dis[] = ['uniacid','=',$input['uniacid']];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
if(!empty($input['id'])){
|
||||
|
||||
$dis[] = ['id','<>',$input['id']];
|
||||
|
||||
}
|
||||
|
||||
$list = $this->where($dis)->select()->toArray();
|
||||
|
||||
if(!empty($list)){
|
||||
|
||||
foreach ($list as $value){
|
||||
|
||||
$res = is_time_cross($input['start_time'],$input['end_time'],$value['start_time'],$value['end_time']);
|
||||
|
||||
if($res==false){
|
||||
|
||||
return ['code'=>500,'msg'=>'该时间段已经有该活动,活动名称:'.$value['title']];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $uniacid
|
||||
* @param $config
|
||||
* @param $store
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-15 16:11
|
||||
*/
|
||||
public function updateSome($id,$uniacid,$spe,$goods_id){
|
||||
|
||||
$config_model = new SeckillConfig();
|
||||
|
||||
$goods_model = new SeckillGoods();
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'atv_id' => $id,
|
||||
|
||||
'goods_id'=> $goods_id
|
||||
];
|
||||
|
||||
$find = $goods_model->dataInfo($insert);
|
||||
|
||||
if(empty($find)){
|
||||
|
||||
$goods_model->dataAdd($insert);
|
||||
|
||||
$atv_id = $goods_model->getLastInsID();
|
||||
|
||||
}else{
|
||||
|
||||
$atv_id = $find['id'];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($spe)){
|
||||
|
||||
foreach ($spe as $value){
|
||||
|
||||
$i_dis = [
|
||||
|
||||
'atv_id' => $id,
|
||||
|
||||
'goods_id'=> $goods_id,
|
||||
|
||||
'spe_id' => $value['spe_id'],
|
||||
];
|
||||
|
||||
$have_stock = $config_model->where($i_dis)->sum('have_stock');
|
||||
|
||||
$value['uniacid'] = $uniacid;
|
||||
|
||||
$value['atv_id'] = $atv_id;
|
||||
|
||||
$value['have_stock'] = $have_stock;
|
||||
|
||||
$config_model->insert($value);
|
||||
|
||||
$arr[] = $config_model->getLastInsID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$config_model->where(['atv_id'=>$atv_id])->where('id','not in',$arr)->delete();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-29 13:54
|
||||
* @功能说明:初始化活动时间
|
||||
*/
|
||||
public function initAtv(){
|
||||
|
||||
$this->where('start_time','>',time())->update(['atv_status'=>1]);
|
||||
|
||||
$this->where('start_time','<',time())->update(['atv_status'=>2]);
|
||||
|
||||
$this->where('end_time','<',time())->update(['atv_status'=>3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-01 10:18
|
||||
* @功能说明:正在进行中的活动
|
||||
*/
|
||||
public function atvIng($goods_id,$spe_id=0,$type=1){
|
||||
|
||||
$this->initAtv();
|
||||
|
||||
if($type==1){
|
||||
|
||||
$dis[] = ['a.atv_status','=',2];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['a.atv_status','in',[1,2]];
|
||||
|
||||
}
|
||||
|
||||
$dis[] = ['b.goods_id','=',$goods_id];
|
||||
|
||||
$dis[] = ['a.status','=',1];
|
||||
|
||||
if(!empty($spe_id)){
|
||||
|
||||
$dis[] = ['c.spe_id','=',$spe_id];
|
||||
}
|
||||
|
||||
// $dis[] = ['c.store_id','=',$store_id];
|
||||
//
|
||||
// $dis[] = ['c.type','=',6];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_v2_seckill_goods b','a.id = b.atv_id')
|
||||
->join('lbfarm_v2_seckill_config c','b.id = c.atv_id')
|
||||
// ->join('lbfarm_v2_goods_store c','a.id = c.goods_id')
|
||||
->where($dis)
|
||||
->field('b.*,a.*,c.price,c.spe_id,c.stock,c.have_stock,a.id as kill_atv_id')
|
||||
->order('c.price')
|
||||
->find();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
$data = $data->toArray();
|
||||
//减去已经销售的
|
||||
$data['stock'] = ($data['stock'] - $data['have_stock'])>0?$data['stock'] - $data['have_stock']:0;
|
||||
|
||||
$spe_model = new GoodsSpePrice();
|
||||
|
||||
$data['init_price'] = $spe_model->where(['id'=>$data['spe_id']])->value('price');
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 14:41
|
||||
* @功能说明:获取是否
|
||||
*/
|
||||
public function getBuyLimit($list,$store_id=0){
|
||||
|
||||
foreach ($list as $value){
|
||||
|
||||
$res = $this->atvIng($value['goods_id'],$value['spe_id']);
|
||||
|
||||
if(!empty($res)){
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-28 15:58
|
||||
* @功能说明:校验用户是否可以参加秒杀
|
||||
*/
|
||||
public function userCheck($user_id,$atv_id,$is_show){
|
||||
|
||||
if(empty($atv_id)){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!empty($atv_id)&&$is_show!=2){
|
||||
|
||||
return ['code'=>500,'msg'=>'秒杀商品不能从购物车下单哦'];
|
||||
}
|
||||
|
||||
$atv = $this->dataInfo(['id'=>$atv_id]);
|
||||
|
||||
if(empty($atv)){
|
||||
|
||||
return ['code'=>500,'msg'=>'秒杀活动已结束'];
|
||||
|
||||
}
|
||||
|
||||
if($atv['is_limit']==1){
|
||||
|
||||
$num = $this->getAtvNum($atv_id,$user_id);
|
||||
|
||||
if($num>=$atv['limit_num']){
|
||||
|
||||
return ['code'=>500,'msg'=>'超过秒杀次数'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @return float
|
||||
* 获取历史商品件数
|
||||
*/
|
||||
public function getAtvNum($id,$user_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.kill_atv_id' => $id,
|
||||
|
||||
'b.user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$order_model = new \app\farm\model\ShopOrderGoods();
|
||||
//取消订单的不算 chen
|
||||
$num = $order_model->alias('a')
|
||||
->join('lbfarm_shop_order b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->group('a.id')
|
||||
->sum('a.goods_num');
|
||||
|
||||
|
||||
$order_id = $order_model->alias('a')
|
||||
->join('lbfarm_shop_order b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->column('b.id');
|
||||
|
||||
$order_refund_goods = new \app\farm\model\ShopRefundGoods();
|
||||
//申请退款成功的
|
||||
$refund_num = $order_refund_goods->where('order_id','in',$order_id)->where(['status'=>2])->sum('goods_num');
|
||||
|
||||
return $num - $refund_num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
206
app/shop/model/ShopGoodsCate.php
Normal file
206
app/shop/model/ShopGoodsCate.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\ShopGoods;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopGoodsCate extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_shop_goods_cate';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'goods_num',
|
||||
|
||||
'store'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-04 17:23
|
||||
*/
|
||||
public function getStoreAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.status' => 2,
|
||||
|
||||
'a.goods_id' => $data['id'],
|
||||
|
||||
'a.type' => 2
|
||||
];
|
||||
|
||||
$store_goods_model = new StoreGoods();
|
||||
|
||||
$list = $store_goods_model->alias('a')
|
||||
->join('lbfarm_farmer b','a.store_id = b.id')
|
||||
->where($dis)
|
||||
->field('a.*,b.title')
|
||||
->group('a.id')
|
||||
->order('a.id dsec')
|
||||
->column('b.id');
|
||||
|
||||
return array_values($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 13:46
|
||||
* @功能说明:分类下面端商品数量
|
||||
*/
|
||||
public function getGoodsNumAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$num = $goods_model->where(['cate_id'=>$data['id']])->where('status','>',-1)->count();
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
if(!empty($data['store'])){
|
||||
|
||||
$store = $data['store'];
|
||||
|
||||
unset($data['store']);
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
if(isset($store)){
|
||||
|
||||
$this->updateSome($id,$store,$data['uniacid']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $data
|
||||
* @param $uniacid
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-04 14:47
|
||||
*/
|
||||
public function updateSome($id,$data,$uniacid){
|
||||
|
||||
$store_goods_model = new StoreGoods();
|
||||
|
||||
$store_goods_model->where(['goods_id'=>$id,'type'=>2])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$insert[$k] = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'store_id'=> $v,
|
||||
|
||||
'goods_id'=> $id,
|
||||
|
||||
'type' => 2
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$store_goods_model->saveAll($insert);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
if(!empty($data['store'])){
|
||||
|
||||
$store = $data['store'];
|
||||
|
||||
unset($data['store']);
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(isset($store)){
|
||||
|
||||
$this->updateSome($dis['id'],$store,$data['uniacid']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
135
app/shop/model/ShopGoodsSpe.php
Normal file
135
app/shop/model/ShopGoodsSpe.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopGoodsSpe extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_shop_spe';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-12 15:28
|
||||
*/
|
||||
public function getImageAttr($value,$data){
|
||||
|
||||
if(!empty($value)){
|
||||
|
||||
return $value;
|
||||
}else{
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* 获取多规格
|
||||
*/
|
||||
public function goodsSpe($dis){
|
||||
$data = $this->where($dis)->select()->toArray();
|
||||
return $this->getTree($data,0);
|
||||
}
|
||||
/**
|
||||
* @param $data
|
||||
* @param $pId
|
||||
* @return array
|
||||
* 递归无限极
|
||||
*/
|
||||
public function getTree($data, $pId){
|
||||
$tree = array();
|
||||
if(!empty($data)){
|
||||
foreach($data as $k => $v) {
|
||||
if($v['pid'] == $pId) {
|
||||
$v['cate'] = $this->getTree($data, $v['id']);
|
||||
$tree[] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return int|string
|
||||
* 添加商品规格
|
||||
*/
|
||||
|
||||
public function goodsSpeAdd($data){
|
||||
$data['create_time'] = time();
|
||||
$data['status'] = 1;
|
||||
$res = $this->insert($data);
|
||||
$res = $this->getLastInsID();
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return int|string
|
||||
* 添加商品规格
|
||||
*/
|
||||
|
||||
public function goodsSpeUpdate($dis,$data){
|
||||
$data['update_time'] = time();
|
||||
$res = $this->where($dis)->update($data);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* 根据条件获取id
|
||||
*/
|
||||
|
||||
public function goodsSpeId($dis){
|
||||
$data = $this->where($dis)->column('id');
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @return array|\think\Model|null
|
||||
* @throws \think\exception\DbException
|
||||
* 获取一个
|
||||
*/
|
||||
public function getSinge($dis){
|
||||
$data = $this->where($dis)->find();
|
||||
return !empty($data)?$data->toArray():$data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* 获取多规格
|
||||
*/
|
||||
public function goodsSpeNot($dis,$data){
|
||||
$data = $this->where($dis)->where('pid','not in',$data)->select()->toArray();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* 获取多规格的pid
|
||||
*/
|
||||
public function goodSpePid($dis){
|
||||
$data = $this->where($dis)->value('pid');
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
1142
app/shop/model/ShopOrder.php
Normal file
1142
app/shop/model/ShopOrder.php
Normal file
File diff suppressed because it is too large
Load Diff
263
app/shop/model/ShopOrderGoods.php
Normal file
263
app/shop/model/ShopOrderGoods.php
Normal file
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopOrderGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_shop_order_goods';
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'refund_num',
|
||||
|
||||
'refund_ing'
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:是否退款中
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-12 10:46
|
||||
*/
|
||||
public function getRefundIngAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$refund_model = new ShopRefund();
|
||||
|
||||
$res = $refund_model->orderRefundIng($data['id']);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:获取退款的数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-12 10:46
|
||||
*/
|
||||
public function getRefundNumAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$refund_model = new ShopRefund();
|
||||
|
||||
$num = $refund_model->refundNum($data['id']);
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataSelect($dis){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->select()->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-22 11:12
|
||||
* @功能说明:添加商品子订单
|
||||
*/
|
||||
public function orderGoodsAdd($order_goods,$order_id,$user_id,$store_id){
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
|
||||
$car_model = new Car();
|
||||
|
||||
foreach ($order_goods as $v){
|
||||
// //限购
|
||||
// if($v['is_limit']==2){
|
||||
// //已购数量
|
||||
// $buy_num = $this->getGoodsNumber(['b.user_id'=>$user_id,'a.goods_id'=>$v['goods_id']]);
|
||||
//
|
||||
// if($v['limit']<$buy_num+$v['goods_num']){
|
||||
//
|
||||
// return ['code'=>500,'msg'=>$v['name'].'超出限购数量,限购数量'.$v['limit']];
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $v['uniacid'],
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'pay_type' => 1,
|
||||
|
||||
'goods_name' => $v['goods_name'],
|
||||
|
||||
'goods_cover' => $v['cover'],
|
||||
|
||||
'spe_name' => $v['spe_name'],
|
||||
|
||||
'goods_price' => $v['price'],
|
||||
|
||||
'pay_price' => $v['true_price'],
|
||||
|
||||
'singe_pay_price'=> $v['true_price']/$v['goods_num'],
|
||||
|
||||
'goods_num' => $v['goods_num'],
|
||||
|
||||
'can_refund_num' => $v['goods_num'],
|
||||
|
||||
'spe_id' => $v['spe_id'],
|
||||
|
||||
'goods_id' => $v['goods_id'],
|
||||
|
||||
];
|
||||
|
||||
$res = $this->dataAdd($insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
return ['code'=>500,'msg'=>'下单失败'];
|
||||
}
|
||||
//减少库存 增加销量
|
||||
$res = $goods_model->setOrDelStock($v['goods_id'],$v['spe_id'],$v['goods_num'],0,0);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
return $res;
|
||||
}
|
||||
//删除购物车
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'goods_id'=> $v['goods_id'],
|
||||
|
||||
'spe_id' => $v['spe_id'],
|
||||
|
||||
'farmer_id' => $store_id
|
||||
];
|
||||
|
||||
$res = $car_model->where($dis)->delete();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @return float
|
||||
* 获取历史商品件数
|
||||
*/
|
||||
public function getGoodsNumber($dis){
|
||||
|
||||
//取消订单的不算 chen
|
||||
$num = $this->alias('a')
|
||||
->join('longbing_card_v2_shop_order_list b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->group('a.id')
|
||||
->sum('a.goods_num');
|
||||
|
||||
|
||||
$order_id = $this->alias('a')
|
||||
->join('longbing_card_v2_shop_order_list b','a.order_id = b.id')
|
||||
->where($dis)
|
||||
->where('b.pay_type','>=',1)
|
||||
->column('b.id');
|
||||
|
||||
$order_refund_goods = new RefundOrderGoods();
|
||||
//申请退款成功的
|
||||
$refund_num = $order_refund_goods->where('order_id','in',$order_id)->where(['status'=>2])->sum('goods_num');
|
||||
|
||||
return $num - $refund_num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
899
app/shop/model/ShopRefund.php
Normal file
899
app/shop/model/ShopRefund.php
Normal file
@@ -0,0 +1,899 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\admin\model\ShopOrderRefund;
|
||||
use app\BaseModel;
|
||||
use app\farm\model\BalanceWater;
|
||||
|
||||
use app\massage\model\CouponRecord;
|
||||
use app\massage\model\User;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopRefund extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_shop_refund_order';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'order_goods',
|
||||
|
||||
'address_info',
|
||||
|
||||
'all_goods_num',
|
||||
|
||||
'store_info',
|
||||
|
||||
'refund_user_name'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-03-08 14:35
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getRefundUserNameAttr($value,$data){
|
||||
|
||||
if(isset($data['refund_user'])&&isset($data['refund_user_admin'])){
|
||||
|
||||
if($data['refund_user_admin']==1){
|
||||
|
||||
$model = new Admin();
|
||||
|
||||
$info = $model->where(['id'=>$data['refund_user']])->value('username');
|
||||
|
||||
}else{
|
||||
|
||||
$model = new \app\farm\model\User();
|
||||
|
||||
$info = $model->where(['id'=>$data['refund_user']])->value('nickName');
|
||||
|
||||
}
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-03-07 17:38
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getStoreInfoAttr($value,$data){
|
||||
|
||||
if(!empty($data['store_id'])){
|
||||
|
||||
$farmer_model= new Farmer();
|
||||
|
||||
$info = $farmer_model->dataInfo(['id'=>$data['store_id'],'type'=>2]);
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 16:48
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getImgsAttr($value,$data){
|
||||
|
||||
if(!empty($value)){
|
||||
|
||||
return explode(',',$value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:总商品数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-25 14:39
|
||||
*/
|
||||
public function getAllGoodsNumAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$order_goods_model = new ShopRefundGoods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'refund_id' => $data['id']
|
||||
];
|
||||
|
||||
$num = $order_goods_model->where($dis)->sum('goods_num');
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-17 17:16
|
||||
* @功能说明:收货信息
|
||||
*/
|
||||
public function getAddressInfoAttr($value,$data){
|
||||
|
||||
if(!empty($data['order_id'])){
|
||||
|
||||
$address_model = new OrderAddress();
|
||||
|
||||
$info = $address_model->dataInfo(['order_id'=>$data['order_id']]);
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-17 17:16
|
||||
* @功能说明:收货信息
|
||||
*/
|
||||
public function getOrderGoodsAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$goods_model = new ShopRefundGoods();
|
||||
|
||||
$info = $goods_model->dataSelect(['refund_id'=>$data['id']]);
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-15 14:37
|
||||
* @功能说明:后台列表
|
||||
*/
|
||||
public function adminDataList($dis,$page=10,$mapor=[]){
|
||||
|
||||
$data = $this->alias('a')
|
||||
|
||||
->join('lbfarm_shop_refund_order_goods c','a.id = c.refund_id')
|
||||
->join('lbfarm_shop_order d','a.order_id = d.id')
|
||||
->join('lbfarm_order_address e','a.order_id = e.order_id AND type = 5','left')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($mapor){
|
||||
$query->whereOr($mapor);
|
||||
})
|
||||
->field('a.*,e.mobile,d.order_code as pay_order_code,e.user_name,d.pay_price')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['nickName'] = $user_model->where(['id'=>$v['user_id']])->value('nickName');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 17:46
|
||||
* @功能说明:小程序退款列表
|
||||
*/
|
||||
public function indexDataList($dis,$where=[],$page=10){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('lbfarm_shop_refund_order_goods c','a.id = c.refund_id')
|
||||
->join('lbfarm_shop_order d','a.order_id = d.id')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field('a.*,d.order_code as pay_order_code')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-08 17:08
|
||||
* @功能说明:退款中
|
||||
*/
|
||||
public function refundIng($cap_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'cap_id' => $cap_id,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$count = $this->where($dis)->count();
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 09:37
|
||||
* @功能说明:通过退款
|
||||
*/
|
||||
public function passOrder($id,$price,$payConfig,$refund_user=0,$text='',$id_admin=0){
|
||||
|
||||
$refund_order= $this->dataInfo(['id'=>$id]);
|
||||
|
||||
$order_model = new ShopOrder();
|
||||
|
||||
$pay_order = $order_model->dataInfo(['id'=>$refund_order['order_id']]);
|
||||
|
||||
if($refund_order['status']!=1){
|
||||
|
||||
return ['code'=>500,'msg'=>'订单状态错误'];
|
||||
}
|
||||
|
||||
$update = [
|
||||
|
||||
'refund_user' => $refund_user,
|
||||
|
||||
'status' => 2,
|
||||
|
||||
'refund_time' => time(),
|
||||
|
||||
'refund_price'=> $price,
|
||||
|
||||
'pay_price' => $price,
|
||||
|
||||
'refund_text' => $text,
|
||||
|
||||
'refund_user_admin' => $id_admin
|
||||
];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $this->dataUpdate(['id'=>$refund_order['id']],$update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'退款失败,请重试'];
|
||||
|
||||
}
|
||||
//修改退款子订单的退款状态
|
||||
$order_refund_goods = new ShopRefundGoods();
|
||||
|
||||
$res = $order_refund_goods->dataUpdate(['refund_id'=>$id],['status'=>2]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'退款失败,请重试1'.$res];
|
||||
|
||||
}
|
||||
|
||||
$goods_model = new ShopGoods();
|
||||
//退换库存
|
||||
foreach ($refund_order['order_goods'] as $v){
|
||||
|
||||
$res = $goods_model->setOrDelStock($v['goods_id'],$v['spe_id'],$v['goods_num'],1,1);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$res = $order_model->dataUpdate(['id'=>$refund_order['order_id']],['true_price'=>$pay_order['true_price']-$price]);
|
||||
//查看货是否退完了
|
||||
$refund_success = $this->checkRefundNum($refund_order['order_id']);
|
||||
//退完了 就修改订单状态
|
||||
if($refund_success==1){
|
||||
|
||||
$res = $order_model->dataUpdate(['id'=>$refund_order['order_id']],['pay_type'=>-1]);
|
||||
//退换优惠券
|
||||
$coupon_model = new CouponRecord();
|
||||
//
|
||||
// $coupon_model->couponRefund($pay_order['id'],2);
|
||||
// if($res==0){
|
||||
//
|
||||
// Db::rollback();
|
||||
//
|
||||
// return ['code'=>500,'msg'=>'退款失败,请重试2'];
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
$pay_order = $order_model->dataInfo(['id'=>$refund_order['order_id']]);
|
||||
|
||||
$refund_order= $this->dataInfo(['id'=>$id]);
|
||||
|
||||
$res = $this->refundCash($payConfig,$pay_order,$price,$refund_order);
|
||||
|
||||
if(!empty($res['code'])){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>$res['msg']];
|
||||
}
|
||||
|
||||
if($res!=true){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'退款失败,请重试3'];
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $payConfig
|
||||
* @param $pay_order
|
||||
* @param $price
|
||||
* @param int $refund_id
|
||||
* @功能说明:退钱
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-07-12 20:31
|
||||
*/
|
||||
public function refundCash($payConfig,$pay_order,$price,$refund_order){
|
||||
|
||||
if($price<=0){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$water_model = new FinanceWater();
|
||||
//说明订单已经完成
|
||||
if($pay_order['type']=-1){
|
||||
//将流水状态修改为可入账
|
||||
$water_model->dataUpdate(['order_id'=>$pay_order['id'],'type'=>8],['cash_status'=>1]);
|
||||
//增加退款流水
|
||||
$water_model->addWater($refund_order['id'],9,2,1);
|
||||
//如果有运费将运费也改为可入账
|
||||
$water_model->dataUpdate(['order_id'=>$pay_order['id'],'type'=>16],['cash_status'=>1]);
|
||||
//增加运费退款流水
|
||||
$water_model->addWater($refund_order['id'],17,1,1);
|
||||
|
||||
}else{
|
||||
|
||||
$water_model->addWater($refund_order['id'],9,2,0);
|
||||
|
||||
$water_model->addWater($refund_order['id'],17,1,0);
|
||||
|
||||
}
|
||||
|
||||
$water_model->cashArrival();
|
||||
|
||||
if(empty($pay_order['balance'])){
|
||||
//微信退款
|
||||
$response = orderRefundApi($payConfig,$pay_order['pay_price'],$price,$pay_order['transaction_id']);
|
||||
//如果退款成功修改一下状态
|
||||
if ( isset( $response[ 'return_code' ] ) && isset( $response[ 'result_code' ] ) && $response[ 'return_code' ] == 'SUCCESS' && $response[ 'result_code' ] == 'SUCCESS' ) {
|
||||
|
||||
$response['out_refund_no'] = !empty($response['out_refund_no'])?$response['out_refund_no']:$pay_order['order_code'];
|
||||
|
||||
$this->dataUpdate(['id'=>$refund_order['id']],['out_refund_no'=>$response['out_refund_no']]);
|
||||
|
||||
}else {
|
||||
//失败就报错
|
||||
$discption = !empty($response['err_code_des'])?$response['err_code_des']:$response['return_msg'];
|
||||
|
||||
return ['code'=>500,'msg'=> $discption];
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
$data = [
|
||||
|
||||
'user_id' => $pay_order['user_id'],
|
||||
|
||||
'pay_price'=> $price,
|
||||
|
||||
'id' => $refund_order['id'],
|
||||
|
||||
'uniacid' => $pay_order['uniacid']
|
||||
];
|
||||
|
||||
$water_model = new \app\farm\model\BalanceWater();
|
||||
|
||||
$res = $water_model->addWater($data,10,1);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 10:29
|
||||
* @功能说明:检查改订单款退完了没
|
||||
*/
|
||||
public function checkRefundNum($order_id,$status=2){
|
||||
|
||||
$order_goods_model = new ShopOrderGoods();
|
||||
|
||||
$order_refund_goods_model = new ShopRefundGoods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order_id
|
||||
];
|
||||
|
||||
$goods_num = $order_goods_model->where($dis)->sum('goods_num');
|
||||
|
||||
if($status==2){
|
||||
|
||||
$dis['status'] = 2;
|
||||
|
||||
$refund_num= $order_refund_goods_model->where($dis)->sum('goods_num');
|
||||
}else{
|
||||
|
||||
$refund_num= $order_refund_goods_model->where($dis)->where('status','in',[1,2])->sum('goods_num');
|
||||
}
|
||||
|
||||
return $refund_num>=$goods_num?1:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-18 15:38
|
||||
* @功能说明:该天的退款
|
||||
*/
|
||||
public function datePrice($date,$uniacid,$cap_id=0,$end_time='',$type=1){
|
||||
|
||||
$end_time = !empty($end_time)?$end_time:$date+86399;
|
||||
|
||||
$dis = [];
|
||||
|
||||
$dis[] = ['status','=',2];
|
||||
|
||||
$dis[] = ['create_time','between',"$date,$end_time"];
|
||||
|
||||
$dis[] = ['uniacid',"=",$uniacid];
|
||||
|
||||
if(!empty($cap_id)){
|
||||
|
||||
$dis[] = ['cap_id','=',$cap_id];
|
||||
}
|
||||
|
||||
if($type==1){
|
||||
|
||||
$price = $this->where($dis)->sum('refund_price');
|
||||
|
||||
return round($price,2);
|
||||
|
||||
}else{
|
||||
|
||||
$count = $this->where($dis)->count();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-26 13:33
|
||||
* @功能说明:申请退款
|
||||
*/
|
||||
public function applyRefund($order,$input){
|
||||
|
||||
$order_goods_model = new ShopOrderGoods();
|
||||
|
||||
$refund_price = 0;
|
||||
|
||||
$integral = 0;
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$list = $input['list'];
|
||||
|
||||
foreach ($list as $k=>$value){
|
||||
|
||||
$order_goods = $order_goods_model->dataInfo(['id'=>$value['id']]);
|
||||
|
||||
if(empty($order_goods)){
|
||||
|
||||
return ['code'=>500,'msg'=>'商品未找到'];
|
||||
}
|
||||
|
||||
if($value['num']>$order_goods['can_refund_num']||$value['num']==0){
|
||||
|
||||
return ['code'=>500,'msg'=>'退款数量错误'];
|
||||
|
||||
}
|
||||
//退款金额
|
||||
$refund_price += $order_goods['singe_pay_price']*$value['num'];
|
||||
|
||||
|
||||
$list[$k]['goods_id'] = $order_goods['goods_id'];
|
||||
|
||||
$list[$k]['goods_name'] = $order_goods['goods_name'];
|
||||
|
||||
$list[$k]['goods_cover'] = $order_goods['goods_cover'];
|
||||
|
||||
$list[$k]['spe_name'] = $order_goods['spe_name'];
|
||||
|
||||
$list[$k]['spe_id'] = $order_goods['spe_id'];
|
||||
|
||||
$list[$k]['goods_price'] = $order_goods['goods_price'];
|
||||
|
||||
$res = $order_goods_model->where(['id'=>$value['id']])->update(['can_refund_num'=>$order_goods['can_refund_num']-$value['num']]);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'申请失败'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if($refund_price<=0){
|
||||
//
|
||||
// Db::rollback();
|
||||
//
|
||||
// return ['code'=>500,'msg'=>'退款金额至少为0.01元'];
|
||||
// }
|
||||
|
||||
$refund_price = round($refund_price,2);
|
||||
|
||||
$refund_price = $refund_price<=$order['pay_price']?$refund_price:$order['pay_price'];
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'store_id' => $order['store_id'],
|
||||
|
||||
'user_id' => $order['user_id'],
|
||||
|
||||
'farmer_id' => $order['farmer_id'],
|
||||
|
||||
'order_code' => orderCode(),
|
||||
|
||||
'apply_price'=> $refund_price,
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'text' => $input['text'],
|
||||
|
||||
'imgs' => !empty($input['imgs'])?implode(',',$input['imgs']):''
|
||||
];
|
||||
|
||||
$res = $this->dataAdd($insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'申请失败'];
|
||||
|
||||
}
|
||||
|
||||
$refund_id = $this->getLastInsID();
|
||||
|
||||
$refund_goods_model = new ShopRefundGoods();
|
||||
|
||||
foreach ($list as $value){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'refund_id' => $refund_id,
|
||||
|
||||
'order_goods_id' => $value['id'],
|
||||
|
||||
'goods_id' => $value['goods_id'],
|
||||
|
||||
'goods_name' => $value['goods_name'],
|
||||
|
||||
'goods_cover' => $value['goods_cover'],
|
||||
|
||||
'spe_name' => $value['spe_name'],
|
||||
|
||||
'spe_id' => $value['spe_id'],
|
||||
|
||||
'goods_num' => $value['num'],
|
||||
|
||||
'goods_price' => $value['goods_price'],
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$res = $refund_goods_model->dataAdd($insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'申请失败'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//查看货是否退完了
|
||||
$refund_success = $this->checkRefundNum($order['id'],1);
|
||||
//退完并且未发货 就退运费
|
||||
if($refund_success==1&&$order['pay_type']<3){
|
||||
|
||||
$refund_price += $order['freight'];
|
||||
|
||||
$refund_price = $refund_price<=$order['pay_price']?$refund_price:$order['pay_price'];
|
||||
|
||||
$this->dataUpdate(['id'=>$refund_id],['apply_price'=>$refund_price,'car_price'=>$order['freight']]);
|
||||
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $refund_id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-12 09:23
|
||||
* @功能说明:获取订单已经退款的数量
|
||||
*/
|
||||
public function refundNum($order_goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.order_goods_id' => $order_goods_id,
|
||||
|
||||
'a.status' => 2
|
||||
];
|
||||
|
||||
$num = $this->alias('a')
|
||||
->join('lbfarm_shop_refund_order_goods b','a.id = b.refund_id')
|
||||
->where($dis)
|
||||
->group('b.order_goods_id')
|
||||
->sum('b.goods_num');
|
||||
|
||||
return $num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-12 09:23
|
||||
* @功能说明:获取订单已经退款的数量
|
||||
*/
|
||||
public function orderRefundIng($order_goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.order_goods_id' => $order_goods_id,
|
||||
|
||||
'a.status' => 1
|
||||
];
|
||||
|
||||
$num = $this->alias('a')
|
||||
->join('lbfarm_shop_refund_order_goods b','a.id = b.refund_id')
|
||||
->where($dis)
|
||||
->group('b.order_goods_id')
|
||||
->find();
|
||||
|
||||
return !empty($num)?1:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-04-12 12:04
|
||||
* @功能说明:拒绝退款
|
||||
*/
|
||||
public function noPassRefund($refund_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $refund_id
|
||||
];
|
||||
|
||||
$refund_order = $this->dataInfo($dis);
|
||||
|
||||
if($refund_order['status']!=1){
|
||||
|
||||
return ['code'=>500,'msg'=>'退款状态错误'];
|
||||
|
||||
}
|
||||
|
||||
$update = [
|
||||
|
||||
'status' => 3,
|
||||
|
||||
'refund_time' => time()
|
||||
|
||||
];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $this->dataUpdate($dis,$update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'退款失败,请重试1'];
|
||||
|
||||
}
|
||||
//修改退款子订单的退款状态
|
||||
$order_refund_goods = new ShopRefundGoods();
|
||||
|
||||
$res = $order_refund_goods->dataUpdate(['refund_id'=>$refund_id],['status'=>3]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return ['code'=>500,'msg'=>'退款失败,请重试2'];
|
||||
|
||||
}
|
||||
//查询通支付订单未退款对售后订单
|
||||
$where[] = ['order_id','=',$refund_order['order_id']];
|
||||
|
||||
$where[] = ['status','=',1];
|
||||
|
||||
$where[] = ['car_price','>',0];
|
||||
|
||||
$find = $this->dataInfo($where);
|
||||
|
||||
if(!empty($find)){
|
||||
|
||||
$apply_price = $find['apply_price'] - $find['car_price'];
|
||||
|
||||
$apply_price = $apply_price>0?$apply_price:0;
|
||||
|
||||
$update = [
|
||||
|
||||
'apply_price' => $apply_price,
|
||||
|
||||
'car_price' => 0
|
||||
];
|
||||
|
||||
$this->dataUpdate(['id'=>$find['id']],$update);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
116
app/shop/model/ShopRefundGoods.php
Normal file
116
app/shop/model/ShopRefundGoods.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopRefundGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_shop_refund_order_goods';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'pay_price'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-12-17 14:10
|
||||
* @功能说明:获取商品实付价格
|
||||
*/
|
||||
public function getPayPriceAttr($value,$data){
|
||||
|
||||
if(!empty($data['order_goods_id'])){
|
||||
|
||||
$order_goods_model = new ShopOrderGoods();
|
||||
|
||||
$price = $order_goods_model->where(['id'=>$data['order_goods_id']])->sum('singe_pay_price');
|
||||
|
||||
return $price;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataSelect($dis){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->select()->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
102
app/shop/model/Signin.php
Normal file
102
app/shop/model/Signin.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Signin extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_signin';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->dataAdd($dis);
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
}
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-24 11:45
|
||||
* @功能说明:发送提醒消息
|
||||
*/
|
||||
public function sendMsg($uniacid){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
185
app/shop/model/SigninRecord.php
Normal file
185
app/shop/model/SigninRecord.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\farm\model\User;
|
||||
use longbingcore\wxcore\PushMsgModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class SigninRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_v2_signin_record';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'create_time_text'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-25 11:37
|
||||
*/
|
||||
public function getCreateTimeTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['create_time'])){
|
||||
|
||||
return date('Y-m-d H:i',$data['create_time']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page=10){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-22 16:11
|
||||
* @功能说明:判断是否是连续签到
|
||||
*/
|
||||
public function initSign($user_id){
|
||||
|
||||
$date = date('Y-m-d',strtotime('-1 day'));
|
||||
|
||||
$today = date('Y-m-d',time());
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'create_date' => $date,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$find = $this->dataInfo($dis);
|
||||
|
||||
if(empty($find)){
|
||||
|
||||
$where[] = ['user_id','=',$user_id];
|
||||
|
||||
$where[] = ['status','=',1];
|
||||
|
||||
$where[] = ['create_date','<>',$today];
|
||||
|
||||
$this->dataUpdate($where,['status'=>0]);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-08-26 14:55
|
||||
* @功能说明:发送消息
|
||||
*/
|
||||
public function sendMsg($uniacid){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$time = date('H',time());
|
||||
|
||||
if($time<10){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$push_model = new PushMsgModel($uniacid);
|
||||
|
||||
$today = strtotime(date('Y-m-d',time()));
|
||||
//开启了签到提醒
|
||||
$dis[] = ['uniacid','=',$uniacid];
|
||||
//今天没有发送过消息
|
||||
$dis[] = ['sign_notice_time','<',$today];
|
||||
//今天未签到
|
||||
$dis[] = ['sign_time','<',$today];
|
||||
|
||||
$data = $user_model->where($dis)->field('id,uniacid,id as user_id')->limit(10)->select()->toArray();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $v){
|
||||
|
||||
$res = $user_model->where(['id'=>$v['user_id']])->where('sign_notice_time','<',$today)->update(['sign_notice_time'=>time()]);
|
||||
|
||||
if($res!=0){
|
||||
|
||||
$push_model->sendMsg($v,14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
113
app/shop/model/StoreGoods.php
Normal file
113
app/shop/model/StoreGoods.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
namespace app\shop\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoreGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
//1商品 2商品分类 3土地分类 4 认养分类 5养殖管理 6秒杀
|
||||
protected $name = 'lbfarm_v2_goods_store';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2022-07-12 16:16
|
||||
* @功能说明:
|
||||
*/
|
||||
public function addData($id,$type,$uniacid,$data){
|
||||
|
||||
$this->where(['goods_id'=>$id,'type'=>$type])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$insert[$k] = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'store_id' => $v,
|
||||
|
||||
'goods_id'=> $id,
|
||||
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$this->saveAll($insert);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
416
app/shop/route/route.php
Normal file
416
app/shop/route/route.php
Normal file
@@ -0,0 +1,416 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
//商城后端路由表
|
||||
Route::group('admin', function () {
|
||||
//商品列表
|
||||
Route::post('Admin/login', 'Admin/login');
|
||||
//配置详情
|
||||
Route::post('AdminSetting/configInfo', 'AdminSetting/configInfo');
|
||||
//配置修改
|
||||
Route::post('AdminSetting/configUpdate', 'AdminSetting/configUpdate');
|
||||
//通知配置详情
|
||||
Route::post('AdminSetting/msgConfigInfo', 'AdminSetting/msgConfigInfo');
|
||||
//通知配置修改
|
||||
Route::post('AdminSetting/msgConfigUpdate', 'AdminSetting/msgConfigUpdate');
|
||||
|
||||
Route::post('AdminSetting/payConfigInfo', 'AdminSetting/payConfigInfo');
|
||||
|
||||
Route::post('AdminSetting/payConfigUpdate', 'AdminSetting/payConfigUpdate');
|
||||
//banne列表
|
||||
Route::post('AdminSetting/bannerList', 'AdminSetting/bannerList');
|
||||
//banner添加
|
||||
Route::post('AdminSetting/bannerAdd', 'AdminSetting/bannerAdd');
|
||||
//banner编辑
|
||||
Route::post('AdminSetting/bannerUpdate', 'AdminSetting/bannerUpdate');
|
||||
//banner详情(id)
|
||||
Route::get('AdminSetting/bannerInfo', 'AdminSetting/bannerInfo');
|
||||
//文章列表(title)
|
||||
Route::get('AdminSetting/articleList', 'AdminSetting/articleList');
|
||||
//添加文章
|
||||
Route::post('AdminSetting/articleAdd', 'AdminSetting/articleAdd');
|
||||
//编辑文章
|
||||
Route::post('AdminSetting/articleUpdate', 'AdminSetting/articleUpdate');
|
||||
//文章详情(id)
|
||||
Route::get('AdminSetting/articleInfo', 'AdminSetting/articleInfo');
|
||||
//文章下拉框
|
||||
Route::get('AdminSetting/articleSelect', 'AdminSetting/articleSelect');
|
||||
//修改密码(pass)
|
||||
Route::post('AdminSetting/updatePass', 'AdminSetting/updatePass');
|
||||
//楼长列表
|
||||
Route::get('AdminCap/capList', 'AdminCap/capList');
|
||||
//楼长数量
|
||||
Route::get('AdminCap/capCount', 'AdminCap/capCount');
|
||||
//修改楼长
|
||||
Route::post('AdminCap/capUpdate', 'AdminCap/capUpdate');
|
||||
//团长下拉框
|
||||
Route::get('AdminCap/capSelect', 'AdminCap/capSelect');
|
||||
//后台提现列表
|
||||
Route::get('AdminCap/walletList', 'AdminCap/walletList');
|
||||
//同意打款(id,status=2,online 1:线上,0线下)
|
||||
Route::post('AdminCap/walletPass', 'AdminCap/walletPass');
|
||||
//拒绝打款(id,status=3)
|
||||
Route::post('AdminCap/walletNoPass', 'AdminCap/walletNoPass');
|
||||
//财务管理
|
||||
Route::post('AdminCap/financeList', 'AdminCap/financeList');
|
||||
//商品列表
|
||||
Route::get('AdminGoods/goodsList', 'AdminGoods/goodsList');
|
||||
//审核商品数量
|
||||
Route::get('AdminGoods/goodsCount', 'AdminGoods/goodsCount');
|
||||
//审核详情
|
||||
Route::get('AdminGoods/shInfo', 'AdminGoods/shInfo');
|
||||
//审核商品详情
|
||||
Route::get('AdminGoods/shGoodsInfo', 'AdminGoods/shGoodsInfo');
|
||||
//同意|驳回申请 status 2 同意 3驳回
|
||||
Route::post('AdminGoods/shUpdate', 'AdminGoods/shUpdate');
|
||||
//用户列表
|
||||
Route::get('AdminUser/userList', 'AdminUser/userList');
|
||||
//退款列表
|
||||
Route::get('AdminOrder/refundOrderList', 'AdminOrder/refundOrderList');
|
||||
//发货
|
||||
Route::post('AdminOrder/orderGoodsSend', 'AdminOrder/orderGoodsSend');
|
||||
//订单列表
|
||||
Route::get('AdminOrder/orderList', 'AdminOrder/orderList');
|
||||
//订单详情
|
||||
Route::get('AdminOrder/orderInfo', 'AdminOrder/orderInfo');
|
||||
//退款详情
|
||||
Route::get('AdminOrder/refundOrderInfo', 'AdminOrder/refundOrderInfo');
|
||||
//拒绝退款
|
||||
Route::post('AdminOrder/noPassRefund', 'AdminOrder/noPassRefund');
|
||||
//同意退款
|
||||
Route::post('AdminOrder/passRefund', 'AdminOrder/passRefund');
|
||||
//某一天的数据统计
|
||||
Route::post('AdminOrder/dateCount', 'AdminOrder/dateCount');
|
||||
//订单导出
|
||||
Route::get('AdminExcel/orderList', 'AdminExcel/orderList');
|
||||
//财务导出
|
||||
Route::get('AdminExcel/dateCount', 'AdminExcel/dateCount');
|
||||
//分类列表
|
||||
Route::get('AdminGoods/goodsCateList', 'AdminGoods/goodsCateList');
|
||||
//添加分类
|
||||
Route::post('AdminGoods/goodsCateAdd', 'AdminGoods/goodsCateAdd');
|
||||
|
||||
Route::post('AdminGoods/goodsCateAdd', 'AdminGoods/goodsCateAdd');
|
||||
|
||||
Route::post('AdminGoods/goodsCateUpdate', 'AdminGoods/goodsCateUpdate');
|
||||
|
||||
Route::get('AdminGoods/goodsCateInfo', 'AdminGoods/goodsCateInfo');
|
||||
//商品列表
|
||||
Route::get('AdminGoods/goodsList', 'AdminGoods/goodsList');
|
||||
//商品详情
|
||||
Route::get('AdminGoods/goodsInfo', 'AdminGoods/goodsInfo');
|
||||
//商品编辑
|
||||
Route::post('AdminGoods/goodsUpdate', 'AdminGoods/goodsUpdate');
|
||||
//商品添加
|
||||
Route::post('AdminGoods/goodsAdd', 'AdminGoods/goodsAdd');
|
||||
//分类下拉框
|
||||
Route::get('AdminGoods/goodsCateSelect', 'AdminGoods/goodsCateSelect');
|
||||
|
||||
Route::post('AdminGoods/updateSpe','AdminGoods/updateSpe');
|
||||
//修改商品基本参数 id 比传
|
||||
Route::post('AdminGoods/goodsBasicUpdate','AdminGoods/goodsBasicUpdate');
|
||||
|
||||
Route::post('AdminGoods/goodsStatusUpdate','AdminGoods/goodsStatusUpdate');
|
||||
//积分列表
|
||||
Route::get('AdminMark/integralList','AdminMark/integralList');
|
||||
//添加积分
|
||||
Route::post('AdminMark/integralAdd','AdminMark/integralAdd');
|
||||
//编辑积分
|
||||
Route::post('AdminMark/integralUpdate','AdminMark/integralUpdate');
|
||||
//积分详情
|
||||
Route::get('AdminMark/integralInfo','AdminMark/integralInfo');
|
||||
|
||||
|
||||
Route::group('AdminGoods', function () {
|
||||
//分类列表
|
||||
Route::get('goodsCateList', 'AdminGoods/goodsCateList');
|
||||
//添加分类
|
||||
Route::post('goodsCateAdd', 'AdminGoods/goodsCateAdd');
|
||||
|
||||
Route::post('goodsCateAdd', 'AdminGoods/goodsCateAdd');
|
||||
|
||||
Route::post('goodsCateUpdate', 'AdminGoods/goodsCateUpdate');
|
||||
|
||||
Route::get('goodsCateInfo', 'AdminGoods/goodsCateInfo');
|
||||
//商品列表
|
||||
Route::get('goodsList', 'AdminGoods/goodsList');
|
||||
//商品详情
|
||||
Route::get('goodsInfo', 'AdminGoods/goodsInfo');
|
||||
//商品编辑
|
||||
Route::post('goodsUpdate', 'AdminGoods/goodsUpdate');
|
||||
//商品添加
|
||||
Route::post('goodsAdd', 'AdminGoods/goodsAdd');
|
||||
//分类下拉框
|
||||
Route::get('goodsCateSelect', 'AdminGoods/goodsCateSelect');
|
||||
|
||||
Route::post('updateSpe','AdminGoods/updateSpe');
|
||||
//修改商品基本参数 id 比传
|
||||
Route::post('goodsBasicUpdate','AdminGoods/goodsBasicUpdate');
|
||||
|
||||
Route::post('goodsStatusUpdate','AdminGoods/goodsStatusUpdate');
|
||||
|
||||
Route::post('goodsCopy','AdminGoods/goodsCopy');
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::group('AdminFreight', function () {
|
||||
//分类列表
|
||||
Route::get('tmplList', 'AdminFreight/tmplList');
|
||||
//添加分类
|
||||
Route::post('tmplAdd', 'AdminFreight/tmplAdd');
|
||||
|
||||
Route::post('tmplUpdate', 'AdminFreight/tmplUpdate');
|
||||
|
||||
Route::get('tmplInfo', 'AdminFreight/tmplInfo');
|
||||
|
||||
Route::get('tmplSelect', 'AdminFreight/tmplSelect');
|
||||
|
||||
|
||||
});
|
||||
|
||||
Route::group('AdminMember', function () {
|
||||
//分类列表
|
||||
Route::get('memberList', 'AdminMember/memberList');
|
||||
//添加分类
|
||||
Route::get('memberSelect', 'AdminMember/memberSelect');
|
||||
|
||||
Route::post('memberAdd', 'AdminMember/memberAdd');
|
||||
|
||||
Route::post('memberUpdate', 'AdminMember/memberUpdate');
|
||||
|
||||
Route::get('memberInfo', 'AdminMember/memberInfo');
|
||||
|
||||
|
||||
});
|
||||
|
||||
Route::group('AdminMark', function () {
|
||||
//分类列表
|
||||
Route::get('integralList', 'AdminMark/integralList');
|
||||
|
||||
Route::post('integralAdd', 'AdminMark/integralAdd');
|
||||
|
||||
Route::post('integralUpdate', 'AdminMark/integralUpdate');
|
||||
|
||||
Route::get('integralInfo', 'AdminMark/integralInfo');
|
||||
|
||||
Route::get('signInfo', 'AdminMark/signInfo');
|
||||
|
||||
Route::post('signUpdate', 'AdminMark/signUpdate');
|
||||
|
||||
Route::get('luckList', 'AdminMark/luckList');
|
||||
|
||||
Route::get('luckInfo', 'AdminMark/luckInfo');
|
||||
|
||||
Route::post('luckAdd', 'AdminMark/luckAdd');
|
||||
|
||||
Route::post('luckUpdate', 'AdminMark/luckUpdate');
|
||||
|
||||
Route::get('killList', 'AdminMark/killList');
|
||||
|
||||
Route::get('killInfo', 'AdminMark/killInfo');
|
||||
|
||||
Route::post('killAdd', 'AdminMark/killAdd');
|
||||
|
||||
Route::post('killUpdate', 'AdminMark/killUpdate');
|
||||
|
||||
Route::post('addKillGoods', 'AdminMark/addKillGoods');
|
||||
|
||||
Route::post('killGoodsDel', 'AdminMark/killGoodsDel');
|
||||
|
||||
Route::get('killGoodsList', 'AdminMark/killGoodsList');
|
||||
|
||||
Route::get('killGoodsInfo', 'AdminMark/killGoodsInfo');
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//商城后端路由表
|
||||
Route::group('app', function () {
|
||||
//用户授权
|
||||
Route::post('IndexUser/userUpdate', 'IndexUser/userUpdate');
|
||||
//申请团长
|
||||
Route::post('IndexUser/capApply', 'IndexUser/capApply');
|
||||
|
||||
Route::get('IndexUser/userInfo', 'IndexUser/userInfo');
|
||||
//用户|团长个人中心
|
||||
Route::get('IndexUser/index', 'IndexUser/index');
|
||||
//个人团长信息
|
||||
Route::get('IndexUser/capInfo', 'IndexUser/capInfo');
|
||||
//用户地址列表
|
||||
Route::get('IndexUser/addressList', 'IndexUser/addressList');
|
||||
//地址详情
|
||||
Route::get('IndexUser/addressInfo', 'IndexUser/addressInfo');
|
||||
//添加地址
|
||||
Route::post('IndexUser/addressAdd', 'IndexUser/addressAdd');
|
||||
//编辑地址
|
||||
Route::post('IndexUser/addressUpdate', 'IndexUser/addressUpdate');
|
||||
//删除地址
|
||||
Route::post('IndexUser/addressDel', 'IndexUser/addressDel');
|
||||
|
||||
Route::get('IndexUser/signinIndex', 'IndexUser/signinIndex');
|
||||
|
||||
Route::get('IndexUser/signinRecordList', 'IndexUser/signinRecordList');
|
||||
|
||||
Route::post('IndexUser/signin', 'IndexUser/signin');
|
||||
//积分记录(add 1积分记录 2积分换购)
|
||||
Route::get('IndexUser/integralList', 'IndexUser/integralList');
|
||||
|
||||
Route::get('IndexUser/integralGoodsList', 'IndexUser/integralGoodsList');
|
||||
|
||||
Route::get('Index/userInfo', 'Index/userInfo');
|
||||
//获取配置信息
|
||||
Route::get('Index/configInfo', 'Index/configInfo');
|
||||
//文章详情(id)
|
||||
Route::get('Index/articleInfo', 'Index/articleInfo');
|
||||
//团长修改自己的个人信息
|
||||
Route::post('IndexCap/capUpdate', 'IndexCap/capUpdate');
|
||||
//团长商品分类列表
|
||||
Route::get('IndexCap/goodsCateList', 'IndexCap/goodsCateList');
|
||||
//团长添加商品分类
|
||||
Route::post('IndexCap/goodsCateAdd', 'IndexCap/goodsCateAdd');
|
||||
//团长编辑商品分类
|
||||
Route::post('IndexCap/goodsCateUpdate', 'IndexCap/goodsCateUpdate');
|
||||
//团长商品分类下拉框
|
||||
Route::post('IndexCap/goodsCateSelect', 'IndexCap/goodsCateSelect');
|
||||
//团长端商品列表(status)
|
||||
Route::get('IndexCap/goodsList', 'IndexCap/goodsList');
|
||||
//团长端添加商品
|
||||
Route::post('IndexCap/goodsAdd', 'IndexCap/goodsAdd');
|
||||
//团长端编辑商品
|
||||
Route::post('IndexCap/goodsUpdate', 'IndexCap/goodsUpdate');
|
||||
//团长端商品信息
|
||||
Route::get('IndexCap/goodsInfo', 'IndexCap/goodsInfo');
|
||||
//批量上下架
|
||||
Route::post('IndexCap/someGoodsUpdate', 'IndexCap/someGoodsUpdate');
|
||||
//团长端提交商品审核(goods_id)
|
||||
Route::post('IndexCap/subGoodsSh', 'IndexCap/subGoodsSh');
|
||||
//团长端商品上下架(id,status)
|
||||
Route::post('IndexCap/goodsStatusUpdate', 'IndexCap/goodsStatusUpdate');
|
||||
//商品各个状态下的数量
|
||||
Route::post('IndexCap/goodsCount', 'IndexCap/goodsCount');
|
||||
//团长核销订单(id)
|
||||
Route::post('IndexCap/hxOrder', 'IndexCap/hxOrder');
|
||||
//订单列表
|
||||
Route::get('IndexCap/orderList', 'IndexCap/orderList');
|
||||
//商品审核列表
|
||||
Route::get('IndexCap/shList', 'IndexCap/shList');
|
||||
|
||||
Route::get('IndexCap/shInfo', 'IndexCap/shInfo');
|
||||
//团长端退款列表
|
||||
Route::get('IndexCap/refundOrderList', 'IndexCap/refundOrderList');
|
||||
//团长同意退款(id,price)
|
||||
Route::post('IndexCap/passRefund', 'IndexCap/passRefund');
|
||||
//团长拒绝退款(id)
|
||||
Route::post('IndexCap/noPassRefund', 'IndexCap/noPassRefund');
|
||||
//团长佣金信息
|
||||
Route::get('IndexCap/capCashInfo', 'IndexCap/capCashInfo');
|
||||
//提现记录
|
||||
Route::get('IndexCap/capCashList', 'IndexCap/capCashList');
|
||||
//申请提现(apply_cash,text)
|
||||
Route::post('IndexCap/applyWallet', 'IndexCap/applyWallet');
|
||||
|
||||
Route::get('IndexGoods/indexCapList', 'IndexGoods/indexCapList');
|
||||
//选择楼长(cap_id)
|
||||
Route::post('IndexGoods/selectCap', 'IndexGoods/selectCap');
|
||||
//分类列表
|
||||
Route::get('IndexGoods/cateList', 'IndexGoods/cateList');
|
||||
//商品首页信息
|
||||
Route::get('IndexGoods/index', 'IndexGoods/index');
|
||||
//购物车信息
|
||||
Route::get('IndexGoods/carInfo', 'IndexGoods/carInfo');
|
||||
//商品列表
|
||||
Route::get('IndexGoods/goodsList', 'IndexGoods/goodsList');
|
||||
|
||||
Route::get('IndexGoods/shopCouponList', 'IndexGoods/shopCouponList');
|
||||
//用户领取优惠券coupon_id
|
||||
Route::get('IndexGoods/userGetCoupon', 'IndexGoods/userGetCoupon');
|
||||
//商品详情
|
||||
Route::get('IndexGoods/killAtvList', 'IndexGoods/killAtvList');
|
||||
|
||||
Route::get('IndexGoods/killGoodsList', 'IndexGoods/killGoodsList');
|
||||
|
||||
Route::get('IndexGoods/hotGoodsList', 'IndexGoods/hotGoodsList');
|
||||
|
||||
Route::get('IndexGoods/luckInfo', 'IndexGoods/luckInfo');
|
||||
|
||||
Route::get('IndexGoods/luckRecord', 'IndexGoods/luckRecord');
|
||||
|
||||
Route::get('IndexGoods/userLuckRecord', 'IndexGoods/userLuckRecord');
|
||||
|
||||
Route::post('IndexGoods/luckDraw', 'IndexGoods/luckDraw');
|
||||
|
||||
Route::post('IndexGoods/killNotice', 'IndexGoods/killNotice');
|
||||
|
||||
|
||||
|
||||
//添加购物车(goods_id,spe_id,goods_num = 1)
|
||||
Route::post('IndexGoods/addCar', 'IndexGoods/addCar');
|
||||
//删除购物车|减少购物车商品数量(id,goods_num=1)
|
||||
Route::post('IndexGoods/delCar', 'IndexGoods/delCar');
|
||||
//批量删除购物车(ID :arr)
|
||||
Route::post('IndexGoods/delSomeCar', 'IndexGoods/delSomeCar');
|
||||
//
|
||||
Route::post('IndexGoods/carUpdate', 'IndexGoods/carUpdate');
|
||||
//
|
||||
Route::post('IndexOrder/payOrder', 'IndexOrder/payOrder');
|
||||
|
||||
Route::get('IndexOrder/payOrderInfo', 'IndexOrder/payOrderInfo');
|
||||
|
||||
Route::get('IndexOrder/goodsSendType', 'IndexOrder/goodsSendType');
|
||||
//用户订单列表(pay_type,name)
|
||||
Route::get('IndexOrder/orderList', 'IndexOrder/orderList');
|
||||
//订单详情
|
||||
Route::get('IndexOrder/orderInfo', 'IndexOrder/orderInfo');
|
||||
//重新支付
|
||||
Route::post('IndexOrder/rePayOrder', 'IndexOrder/rePayOrder');
|
||||
//取消订单
|
||||
Route::post('IndexOrder/cancelOrder', 'IndexOrder/cancelOrder');
|
||||
//申请退款(order_id,list:['id','num'])
|
||||
Route::post('IndexOrder/applyOrder', 'IndexOrder/applyOrder');
|
||||
//取消退款
|
||||
Route::post('IndexOrder/cancelRefundOrder', 'IndexOrder/cancelRefundOrder');
|
||||
//用户端退款列表(name,status)
|
||||
Route::get('IndexOrder/refundOrderList', 'IndexOrder/refundOrderList');
|
||||
//退款详情
|
||||
Route::get('IndexOrder/refundOrderInfo', 'IndexOrder/refundOrderInfo');
|
||||
//刷新订单二维码(id)
|
||||
Route::post('IndexOrder/refreshQr', 'IndexOrder/refreshQr');
|
||||
|
||||
Route::post('IndexOrder/endOrder', 'IndexOrder/endOrder');
|
||||
|
||||
Route::get('IndexOrder/couponList', 'IndexOrder/couponList');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
//支付
|
||||
Route::any('IndexWxPay/returnPay', 'IndexWxPay/returnPay');
|
||||
|
||||
Route::any('IndexWxPay/aliNotify', 'IndexWxPay/aliNotify');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
82
app/shop/server/Coupon.php
Normal file
82
app/shop/server/Coupon.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace app\shop\server;
|
||||
use app\ApiRest;
|
||||
use app\BaseController;
|
||||
use app\member\model\Config;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Member;
|
||||
use app\member\model\StoredOrder;
|
||||
use app\publics\model\TmplConfig;
|
||||
use app\shop\model\BargainRecord;
|
||||
use longbingcore\wxcore\WxTmpl;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
use app\shop\model\IndexShopOrder as OrderModel;
|
||||
use app\shop\model\IndexUserInfo;
|
||||
use app\shop\model\IndexUser;
|
||||
use app\shop\model\IndexGoods;
|
||||
use app\shop\model\IndexShopSpePrice;
|
||||
use app\shop\model\IndexAddress;
|
||||
use app\shop\model\IndexShopOrderGoods;
|
||||
use app\shop\model\IndexCouponRecord;
|
||||
use app\shop\model\IndexShopCollageList;
|
||||
use app\shop\model\IndexUserCollage;
|
||||
use app\shop\model\IndexSellingProfit;
|
||||
use app\shop\model\IndexSellingWater;
|
||||
use app\shop\model\IndexCardCount;
|
||||
use work;
|
||||
|
||||
|
||||
class Coupon
|
||||
{
|
||||
|
||||
public $_observer = [];
|
||||
|
||||
|
||||
public function __construct() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @purpose: 添加观察者
|
||||
* @param string $key 给所添加的观察者的一个唯一 key,方便从注册树中移除观察者
|
||||
* @param Observer $observer 观察者对象
|
||||
* @return mixed
|
||||
*/
|
||||
public function addObserver( $observer)
|
||||
{
|
||||
$this->_observer[] = $observer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @purpose: 从注册树中移除观察者
|
||||
* @param string $key 给所添加的观察者的一个唯一 key,方便从注册树中移除观察者
|
||||
* @return mixed
|
||||
*/
|
||||
public function removeObserver($key)
|
||||
{
|
||||
unset($this->_observer[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @purpose: 广播通知以注册的观察者,对注册树进行遍历,让每个对象实现其接口提供的操作
|
||||
* @return mixed
|
||||
*/
|
||||
public function notify($id,$data)
|
||||
{
|
||||
if(!empty($this->_observer)){
|
||||
|
||||
foreach ($this->_observer as $observer) {
|
||||
|
||||
$data[] = $observer->eventCoupon($id,$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return !empty($data)?$data:[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user