初始化代码

This commit is contained in:
2025-12-22 14:32:54 +08:00
parent e27ab90d9f
commit d02b31a8b9
1459 changed files with 240973 additions and 0 deletions

View File

@@ -0,0 +1,132 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\BaseController;
use think\App;
use app\farm\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 );
}
}

View File

@@ -0,0 +1,191 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use think\App;
use think\facade\Db;
class AdminBalance extends AdminRest
{
protected $model;
protected $order_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->order_model = new BalanceOrder();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值充值卡列表
*/
public function cardList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加充值卡
*/
public function cardAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑充值卡
*/
public function cardUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:充值卡详情
*/
public function cardInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值订单列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
if(!empty($input['order_code'])){
$dis[] = ['order_code','like','%'.$input['order_code'].'%'];
}
if(!empty($input['start_time'])){
$dis[] = ['pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->order_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:充值订单详情
*/
public function orderInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->order_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use app\farm\model\Breed;
use app\farm\model\Farmer;
use app\farm\model\LandList;
use app\farm\model\Massif;
use app\farm\model\Source;
use app\farm\server\Land;
use think\App;
use think\facade\Db;
class AdminBreed extends AdminRest
{
protected $model;
protected $massif_model;
protected $land_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->massif_model = new Massif();
$this->land_model = new LandList();
}
/**
* @author chenniang
* @DataTime: 2021-12-29 10:29
* @功能说明:养殖管理
*/
public function breedList(){
$input = $this->_param;
$breed_model = new Breed();
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','>',-1];
if(!empty($input['title'])){
$dis[] = ['a.title','like','%'.$input['title'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['b.farmer_id','=',$input['farmer_id']];
$dis[] = ['b.type','=',5];
}
$data = $breed_model->breedList($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['farmer_id'])->column('title');
$v['farmer_name'] = implode(',',$v['farmer_name']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-29 10:30
* @功能说明:添加养殖管理
*/
public function breedAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$breed_model = new Breed();
$res = $breed_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-29 10:34
* @功能说明:编辑养殖管理
*/
public function breedUpdate(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$dis = [
'id' => $input['id']
];
$breed_model = new Breed();
$res = $breed_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-29 10:34
* @功能说明:编辑养殖管理
*/
public function breedInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$breed_model = new Breed();
$res = $breed_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,834 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\Claim;
use app\farm\model\ClaimCollage;
use app\farm\model\ClaimOrder;
use app\farm\model\ClaimText;
use app\farm\model\CollageJoin;
use app\farm\model\Config;
use app\farm\model\Farmer;
use app\farm\model\LandCate;
use app\farm\model\LandOrder;
use app\farm\model\LandOrderSeed;
use app\farm\model\Machine;
use app\farm\model\Monitor;
use app\farm\model\MonitorText;
use app\farm\model\OrderAddress;
use app\farm\model\SendOrder;
use app\farm\model\Source;
use app\farm\model\User;
use app\shop\model\FreightTemplate;
use think\App;
use app\farm\model\Config as Model;
use think\facade\Db;
class AdminClaim extends AdminRest
{
protected $model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
}
/**
* @author chenniang
* @DataTime: 2021-12-10 17:10
* @功能说明:领地 认养分类列表
*/
public function claimCateList(){
$input = $this->_param;
$cate_model = new LandCate();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$dis[] = ['type','=',$input['type']];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$data = $cate_model->dataList($dis,$input['limit']);
if(!empty($data['data'])){
$farmer_model = new Farmer();
foreach ($data['data'] as &$v){
$v['farmer_title'] = $farmer_model->where('id','in',$v['farmer_id'])->where(['status'=>2])->column('title');
$v['farmer_title'] = array_values($v['farmer_title']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 15:04
* @功能说明:配置详情
*/
public function claimCateInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$cate_model = new LandCate();
$data = $cate_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 15:04
* @功能说明:领地 认养分类编辑
*/
public function claimCateUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$cate_model = new LandCate();
$input['uniacid'] = $this->_uniacid;
$data = $cate_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-10 17:13
* @功能说明:领地 认养分类添加
*/
public function claimCateAdd(){
$input = $this->_input;
$cate_model = new LandCate();
$input['uniacid'] = $this->_uniacid;
$data = $cate_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-28 11:26
* @功能说明:用户下单列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
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['goods_name'])){
$dis[] = ['a.goods_name','like','%'.$input['goods_name'].'%'];
}
if(!empty($input['mobile'])){
$dis[] = ['b.mobile','like','%'.$input['mobile'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['a.farmer_id','=',$input['farmer_id']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$order_model = new ClaimOrder();
$farmer_model = new Farmer();
$user_model = new User();
$data = $order_model->adminDataList($dis,$input['limit']);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['farmer_info'] = $farmer_model->dataInfo(['id'=>$v['farmer_id']],'title');
$v['user_info'] = $user_model->dataInfo(['id'=>$v['user_id']]);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-28 11:52
* @功能说明:用户下单详情
*/
public function orderInfo(){
$input = $this->_param;
$farmer_model = new Farmer();
$source_model = new Source();
$dis = [
'id' => $input['id']
];
$order_model = new ClaimOrder();
$data = $order_model->dataInfo($dis);
$data['time_text'] = date('Y-m-d',$data['start_time']).'~'.date('Y-m-d',$data['end_time']);
//农场信息
$data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']]);
//溯源信息
$data['source'] = $source_model->dataInfo(['id'=>$data['source_id']]);
$address_model = new OrderAddress();
$data['address_info'] = $address_model->dataInfo(['order_id'=>$input['id'],'type'=>2]);
if($data['is_collage']==1){
$collage_model = new CollageJoin();
$collage_info = $collage_model->dataInfo(['order_id'=>$input['id']]);
if(!empty($collage_info)){
$data['collage_status'] = $collage_info['status'];
$data['collage_discount_price'] = $data['init_price']-$collage_info['price'];
$data['collage_discount_price'] = $data['collage_discount_price']>0?$data['collage_discount_price']:0;
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-02-08 17:14
* @功能说明:配送订单列表
*/
public function userSendOrderList(){
$input = $this->_param;
$send_order_model = new SendOrder();
$data = $send_order_model->orderSendOrder($input['claim_order_id'],1,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-02-16 17:21
* @功能说明:配送订单列表
*/
public function sendOrderList(){
$input = $this->_param;
$send_order_model = new SendOrder();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['pay_time','>',0];
if(!empty($input['pay_type'])){
$dis[] = ['pay_type','=',$input['pay_type']];
}
if(!empty($input['type'])){
$dis[] = ['type','=',$input['type']];
}
if(!empty($input['send_type'])){
$dis[] = ['send_type','=',$input['send_type']];
}
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
$data = $send_order_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-02-09 14:00
* @功能说明:配送订单详情
*/
public function sendOrderInfo()
{
$input = $this->_param;
$send_order_model = new SendOrder();
$seed_model = new LandOrderSeed;
$farmer_model = new Farmer();
$send_order = $send_order_model->dataInfo(['id' => $input['id']]);
if($send_order['type']==1){
$order_model = new ClaimOrder();
$send_order['claim_order'] = $order_model->dataInfo(['id' => $send_order['order_id']]);
}else{
$order_model = new LandOrder();
$send_order['land_order'] = $order_model->dataInfo(['id' => $send_order['order_id']]);
//种子列表
$send_order['land_order']['seed'] = $seed_model->orderSeed($send_order['order_id']);
}
$send_order['farmer_info'] = $farmer_model->dataInfo(['id'=>$send_order['farmer_id']]);
return $this->success($send_order);
}
/**
* @author chenniang
* @DataTime: 2022-02-09 10:24
* @功能说明:配送订单收货
*/
public function sendOrderReceiving(){
$input = $this->_input;
$send_order_model = new SendOrder();
$send_order = $send_order_model->dataInfo(['id'=>$input['id']]);
if(empty($send_order)){
$this->errorMsg('订单未找到');
}
if($send_order['pay_type']!=2&&$send_order['send_type']==1){
$this->errorMsg('订单状态错误');
}
if($send_order['pay_type']!=3&&$send_order['send_type']==2){
$this->errorMsg('订单状态错误');
}
$res = $send_order_model->sendOrderReceiving($send_order);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-02-09 09:47
* @功能说明:发货订单发货
*/
public function sendOrderSend(){
$input = $this->_input;
$send_order_model = new SendOrder();
$send_order = $send_order_model->dataInfo(['id'=>$input['id']]);
if(empty($send_order)){
$this->errorMsg('订单未找到');
}
if($send_order['pay_type']!=2){
$this->errorMsg('订单状态错误');
}
$config_model = new Config();
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
$update = [
'pay_type' => 3,
'send_time'=> time(),
'auto_receiving_time' => $config['auto_hx_time']*86400+time()
];
Db::startTrans();
$res = $send_order_model->dataUpdate(['id'=>$input['id']],$update);
if($res==0){
Db::rollback();
$this->errorMsg('发货失败');
}
if($send_order['type']==1){
$claim_order_model = new ClaimOrder();
$claim_order_model->dataUpdate(['id'=>$send_order['order_id']],['pay_type'=>3]);
}
Db::commit();
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-07-01 15:06
* @功能说明:认养拼团列表
*/
public function collageList(){
$input = $this->_param;
$collage_model = new ClaimCollage();
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','>',-1];
if(!empty($input['title'])){
$dis[] = ['a.title','like','%'.$input['title'].'%'];
}
if(!empty($input['goods_name'])){
$dis[] = ['b.title','like','%'.$input['goods_name'].'%'];
}
$data = $collage_model->adminDataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-01 15:11
* @功能说明:添加拼团
*/
public function collageAdd(){
$input = $this->_input;
$collage_model = new ClaimCollage();
$input['uniacid'] = $this->_uniacid;
$res = $collage_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-07-01 15:11
* @功能说明:添加拼团
*/
public function collageUpdate(){
$input = $this->_input;
$collage_model = new ClaimCollage();
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$res = $collage_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-07-01 15:11
* @功能说明:添加拼团
*/
public function collageInfo(){
$input = $this->_param;
$collage_model = new ClaimCollage();
$dis = [
'id' => $input['id']
];
$res = $collage_model->dataInfo($dis);
$claim_model = new Claim();
$res['claim_title'] = $claim_model->where(['id'=>$res['claim_id']])->value('title');
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 15:28
* @功能说明:认养管理列表
*/
public function claimList(){
$input = $this->_param;
$claim_model = new Claim();
$dis[] = ['uniacid','=',$this->_uniacid];
if(isset($input['status'])){
$dis[] = ['status','=',$input['status']];
}else{
$dis[] = ['status','>',-1];
}
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$data = $claim_model->dataList($dis,$input['limit']);
if(!empty($data['data'])){
$farmer_model = new Farmer();
$cate_model = new LandCate();
foreach ($data['data'] as &$v){
$v['farmer_name'] = $farmer_model->where(['id'=>$v['farmer_id']])->value('title');
$cate_name = $cate_model->where('id','in',$v['cate_id'])->column('title');
$v['cate_name'] = implode(',',$cate_name);
}
}
$arr = [
0 => 'off_num',
1 => 'on_num',
];
foreach ($arr as $key => $value){
$dis = [
'uniacid' => $this->_uniacid,
'status' => $key
];
$data[$value] = $claim_model->where($dis)->count();
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 16:32
* @功能说明:添加认养
*/
public function claimAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$claim_model = new Claim();
$res = $claim_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 16:32
* @功能说明:认养详情
*/
public function claimInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$claim_model = new Claim();
$res = $claim_model->dataInfo($dis);
$claim_text_model = new ClaimText();
$monitor_text_model= new MonitorText();
//流程
$res['process'] = $claim_text_model->where(['claim_id'=>$input['id']])->select()->toArray();
//监控
$res['monitor'] = $monitor_text_model->where(['obj_id'=>$input['id'],'type'=>2])->column('monitor_id');
$res['monitor'] = array_values($res['monitor']);
$freightTemplate_model = new FreightTemplate();
$res['send_template_type'] = $freightTemplate_model->where(['id'=>$res['send_tmpl_id']])->value('type');
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 16:32
* @功能说明:编辑认养
*/
public function claimUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$claim_model = new Claim();
$res = $claim_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 16:32
* @功能说明:编辑认养
*/
public function claimStatusUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$claim_model = new Claim();
$res = $claim_model->where($dis)->update($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-31 15:11
* @功能说明:认养和土地分类
*/
public function landAndClaimCate(){
$input = $this->_param;
$dis = [
'a.status' => 1,
'a.uniacid'=> $this->_uniacid,
'a.type' => $input['type']
];
$where = [];
if(!empty($input['farmer_id'])){
$where = [
'a.is_public' => 1,
'b.farmer_id' => $this->farmer['id']
];
}
$cate_model = new LandCate();
$data = $cate_model->alias('a')
->join('lbfarm_land_cate_text b','a.id = b.cate_id','left')
->where($dis)
->where(function ($query) use ($where){
$query->whereOr($where);
})
->field('a.*')
->group('a.id')
->order('a.top desc,a.id desc')
->select()
->toArray();
return $this->success($data);
}
}

View File

@@ -0,0 +1,372 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BagAtv;
use app\farm\model\Coupon;
//use app\farm\model\CouponAtv;
//use app\farm\model\CouponAtvRecord;
use app\farm\model\CouponRecord;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class AdminCoupon extends AdminRest
{
protected $model;
protected $atv_model;
protected $record_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Coupon();
$this->atv_model = new BagAtv();
$this->record_model = new CouponRecord();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:优惠券列表
*/
public function couponList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['status','=',$input['status']];
}else{
$dis[] = ['status','>',-1];
}
if(isset($input['send_type'])){
$dis[] = ['send_type','=',$input['send_type']];
}
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加优惠券
*/
public function couponAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑优惠券
*/
public function couponUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-02 09:51
* @功能说明:卡券上下架删除
*/
public function couponStatusUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
//删除优惠券 需要判断该优惠券是否正在参加活动
if(isset($input['status'])&&$input['status']==-1){
$atv_record_model = new CouponAtvRecord();
$have_atv = $atv_record_model->couponIsAtv($input['id']);
if($have_atv==true){
$this->errorMsg('该优惠券正在参加活动,只有等用户发起等活动结束后才能删除');
}
}
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:优惠券详情
*/
public function couponInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-06 19:19
* @功能说明:活动详情
*/
public function couponAtvInfo(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid
];
$data = $this->atv_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-06 19:22
* @功能说明:活动编辑
*/
public function couponAtvUpdate(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid
];
$input['uniacid'] = $this->_uniacid;
$data = $this->atv_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-12 16:26
* @功能说明:后台派发卡劵
*/
public function couponRecordAdd(){
$input = $this->_input;
foreach ($input['user'] as $value){
$res = $this->record_model->recordAdd($input['coupon_id'],$value['id'],$value['num']);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 14:31
* @功能说明:优惠券下拉框
*/
public function couponSelect(){
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1
];
$data = $this->model->where($dis)->order('id desc')->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 14:36
* @功能说明:活动列表
*/
public function bagAtvList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like',"%".$input['title'].'%'];
}
$data = $this->atv_model->dataList($dis,$input['limie']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 14:39
* @功能说明:添加活动
*/
public function bagAtvAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$input = $this->atv_model->changeData($input);
$res = $this->atv_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 14:39
* @功能说明:添加活动
*/
public function bagAtvUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$input = $this->atv_model->changeData($input);
$res = $this->atv_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 14:39
* @功能说明:添加活动
*/
public function bagAtvInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$res = $this->atv_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,693 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\ClaimOrder;
use app\farm\model\Farmer;
use app\farm\model\FinanceWater;
use app\farm\model\LandOrder;
use app\farm\model\ShopOrder;
use app\farm\model\User;
use app\farm\model\Wallet;
use app\shop\model\DistributionCash;
use app\shop\model\DistributionList;
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 LandOrder();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:列表
*/
public function landOrderList(){
$input = $this->_param;
$order_model = new LandOrder();
$farmer_model = new Farmer();
$user_model = new User();
//初始化订单
$order_model->orderInit();
$dis[] = ['a.uniacid','=',$this->_uniacid];
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['goods_name'])){
$dis[] = ['a.goods_name','like','%'.$input['goods_name'].'%'];
}
if(!empty($input['mobile'])){
$dis[] = ['b.mobile','like','%'.$input['mobile'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['a.farmer_id','=',$input['farmer_id']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $order_model->adminDataSelect($dis);
if(!empty($data)){
foreach ($data as &$vs){
$vs['farmer_info'] = $farmer_model->dataInfo(['id'=>$vs['farmer_id']],'title');
$vs['user_info'] = $user_model->dataInfo(['id'=>$vs['user_id']]);
}
}
$name = '土地订单列表';
$header=[
'订单ID',
'商品名',
'到期时间',
'面积',
'农场名称',
'服务类型',
'租赁人',
'租赁人手机号',
'下单人',
'下单人手机号',
'实收金额',
'系统订单号',
'付款订单号',
'下单时间',
'支付方式',
'状态',
];
$new_data = [];
foreach ($data as $v){
$info = array();
$info[] = $v['id'];
$info[] = $v['goods_name'];
$info[] = date('Y-m-d H:i:s',$v['end_time']);
$info[] = $v['area'].'m²';
$info[] = !empty($v['farmer_info']['title'])?$v['farmer_info']['title']:'';
$info[] = $v['massif_title'];
$info[] = $v['rent_user_name'];
$info[] = $v['rent_mobile'];
$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'])&&$v['balance']>0?'余额支付':'微信支付';
$info[] = $this->orderStatusText($v['pay_type']);
$new_data[] = $info;
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-28 11:26
* @功能说明:用户下单列表
*/
public function claimOrderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
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['goods_name'])){
$dis[] = ['a.goods_name','like','%'.$input['goods_name'].'%'];
}
if(!empty($input['mobile'])){
$dis[] = ['b.mobile','like','%'.$input['mobile'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['a.farmer_id','=',$input['farmer_id']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$order_model = new ClaimOrder();
$farmer_model = new Farmer();
$user_model = new User();
$data = $order_model->adminDataSelect($dis);
if(!empty($data)){
foreach ($data as &$vs){
$vs['farmer_info'] = $farmer_model->dataInfo(['id'=>$vs['farmer_id']],'title');
$vs['user_info'] = $user_model->dataInfo(['id'=>$vs['user_id']]);
}
}
$name = '认养订单列表';
$header=[
'订单ID',
'商品名',
'数量',
'配送周期',
'农场名称',
'认养编号',
'下单人',
'下单人手机号',
'实收金额',
'系统订单号',
'付款订单号',
'下单时间',
'支付方式',
'配送方式',
'状态',
];
$new_data = [];
foreach ($data as $v){
$info = array();
$info[] = $v['id'];
$info[] = $v['goods_name'];
$info[] = $v['num'];
$info[] = $v['send_cycle'].'共'.$v['send_times'].'次';
$info[] = $v['farmer_info']['title'];
$info[] = $v['claim_code'];
$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'])&&$v['balance']>0?'余额支付':'微信支付';
$info[] = $v['send_type']==1?'自提':'快递';
$info[] = $this->orderStatusText($v['pay_type'],2);
$new_data[] = $info;
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-08 14:55
* @功能说明:商城订单导出
*/
public function shopOrderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$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']];
}
if(!empty($input['store_id'])){
$dis[] = ['a.store_id','=',$input['store_id']];
}
$order_model = new ShopOrder();
$data = $order_model->adminDataSelect($dis,$where);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-30 16:32
* @功能说明:
*/
public function orderStatusText($status,$type=1){
switch ($status){
case 1:
return '待支付';
break;
case 2:
return $type==1?'租赁中':'认养中';
break;
case 3:
return '配送中';
break;
case 7:
return '已完成';
break;
case -1:
return '已取消';
break;
}
}
/**
* @author chenniang
* @DataTime: 2021-03-18 13:37
* @功能说明:财务数据统计导出
*/
public function dateCount(){
$input = $this->_param;
$water_model = new FinanceWater();
if($input['type']==1){
$where[] = ['farmer_id','=',$input['farmer_id']];
}else{
$where[] = ['store_id','=',$input['farmer_id']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$where[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
// dump($where);exit;
$data = $water_model->where($where)->field('create_date')->group('create_date')->select()->toArray();
if(!empty($data)){
foreach ($data as &$vs){
//查询各个类型的单日的流水除去余额
$date_water = $water_model->getDateList($input['farmer_id'],$vs['create_date'],$input['type']);
$vs = array_merge($vs,$date_water);
//查询当前余额
$day_water = $water_model->getDayCash($input['farmer_id'],$input['type'],$vs['create_date']);
$vs['cash'] = $day_water['cash'];
}
}
$farmer_model = new Farmer();
$farmer_name = $farmer_model->where(['id'=>$input['farmer_id']])->value('title');
$name = $farmer_name.'账务列表';
$header=[
'收支时间',
'土地订单收入(元)',
'土地配送收入(元)',
'认养订单收入(元)',
'认养配送收入(元)',
'养殖订单收入(元)',
'提现(元)',
'余额(元)',
];
$new_data = [];
foreach ($data as $v){
$info = array();
$info[] = $v['create_date'];
$info[] = $v['land_cash'];
$info[] = $v['land_send_cash'];
$info[] = $v['claim_cash'];
$info[] = $v['claim_send_cash'];
$info[] = $v['breed_cash'];
$info[] = $v['wallet_cash'];
$info[] = $v['cash'];
$new_data[] = $info;
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 14:48
* @功能说明:用户收益列表
*/
public function userProfitListExcel(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$where = [];
if(!empty($input['name'])){
$where[] = ['a.nickName','like','%'.$input['name'].'%'];
$where[] = ['b.user_name','like','%'.$input['name'].'%'];
}
$fx_model = new DistributionList();
$cash_model = new DistributionCash();
$wallet_model = new Wallet();
$data = $fx_model->userProfitSelect($dis,$where);
if(!empty($data)){
foreach ($data as &$v){
//产生收益
$v['total_fx_cash'] = $cash_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('cash');
//未入账
$v['unrecorded_fx_cash'] = $cash_model->where(['user_id'=>$v['id']])->where('status','in',[1])->sum('cash');
//累计提现
$v['total_wallte_cash'] = $wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('pay_price');
//提现中
$v['wallte_ing_cash'] = $wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1])->sum('pay_price');
}
}
$name = '收益信息列表';
$header=[
'ID',
'姓名',
'微信昵称',
'总收益',
'总提现',
'提现中',
'未入账',
'当前余额',
];
$new_data = [];
if(!empty($data)){
foreach ($data as $v){
$info = array();
$info[] = $v['id'];
$info[] = !empty($v['user_name'])?$v['user_name']:'';
$info[] = $v['nickName'];
$info[] = $v['total_fx_cash'];
$info[] = $v['total_wallte_cash'];
$info[] = $v['wallte_ing_cash'];
$info[] = $v['unrecorded_fx_cash'];
$info[] = $v['fx_cash'];
$new_data[] = $info;
}
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 10:17
* @功能说明:分销商列表导出
*/
public function userRelationshipListExcel(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid,
'is_fx' => 1
];
$user_model = new User();
$cash_model = new DistributionCash();
$wallet_model = new Wallet();
$data = $user_model->where($dis)->field('id,avatarUrl,nickName,pid,fx_bind_time,fx_cash')->order('fx_bind_time')->select()->toArray();
if(!empty($data)){
foreach ($data as &$v){
$v['top_name'] = $user_model->where(['id'=>$v['pid'],'is_fx'=>1])->value('nickName');
//产生收益
$v['total_fx_cash'] = $cash_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('cash');
//累计提现
$v['wallte_cash'] = $wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('pay_price');
}
}
$name = '分销商列表';
$header=[
'ID',
'微信昵称',
'产生收益(元)',
'总收益(元)',
'已提现(元)',
'上线id',
'上线昵称',
'创建时间',
];
$new_data = [];
if(!empty($data)){
foreach ($data as $v){
$info = array();
$info[] = $v['id'];
$info[] = $v['nickName'];
$info[] = $v['total_fx_cash'];
$info[] = $v['fx_cash'];
$info[] = $v['wallte_cash'];
$info[] = $v['pid'];
$info[] = !empty($v['top_name']);
$info[] = date('Y-m-d H:i:s',$v['fx_bind_time']);
$new_data[] = $info;
}
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($data);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,582 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\ShopGoods;
use app\farm\model\ShopGoodsCate;
use app\member\model\DiscountGoods;
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 Shop;
$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']);
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->_input;
$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);
}
/**
* 获取商品列表
*/
public function goodsList(){
$input= $this->_param;
$dis[]= ['uniacid','=',$this->_uniacid];
if(!empty($input['name'])){
$dis[] = ['name','like',"%".$input['name']."%"];
}
if(!empty($input['cate'])){
$dis[] = ['type','=',$input['cate']];
}
//自提
if(!empty($input['is_self'])){
$dis[] = ['is_self','=',$input['is_self']];
}
//快递
if(!empty($input['is_send'])){
$dis[] = ['is_send','=',$input['is_send']];
}
$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[] = ['status','=',1];
break;
case 2:
$dis[]= ['status','>',-1];
break;
case 3:
$dis[] = ['status','=',0];
break;
}
$dis[] = ['id','in',$sale_out_goods];
$data = $this->model->dataList($dis,$this->_input['limit']);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
//总库存
$v['all_stock'] = $this->spe_price_model->getGoodsStock($v['id']);
//规格
$v['spe_info'] = $this->goodsSpeList($v['id']);
$v['cate_text'] = $this->cate_model->where(['id'=>$v['type']])->value('title');
}
}
//销售中
$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;
$data = $this->model->returnData($input);
$discount_data = $input['memberForm']['discount_data'];
$data['uniacid'] = $this->_uniacid;
Db::startTrans();
$goods_id = $this->model->dataAdd($data);
$spe_arr = $this->goodsSpeAdd($input['specsForm']['specsItem'],$goods_id);
$spe_res = $this->goodsSpePriceAdd($input['specsForm']['specsTable'],$goods_id,$spe_arr);
//会员折扣模型
$discount_model = new DiscountGoods();
//会员折扣
$res = $discount_model->goodsAdd($discount_data,$this->_uniacid,$goods_id);
Db::commit();
return $this->success($res);
}
/**
* 修改商品
*/
public function goodsUpdate(){
$input= $this->_input;
//会员折扣模型
$discount_model = new DiscountGoods();
$dis = is_array($input['id'])? ['id','in',$input['id']]:['id' =>$input['id']];
$discount_data = $input['memberForm']['discount_data'];
Db::startTrans();
$data = $this->model->returnData($input);
//判断商品名字长度
if(strlen($data['name'])>110){
$this->errorMsg('商品名字不得超过110字符当前字符'.strlen($data['name']));
}
if(isset($data['is_limit'])&&$data['is_limit']==2&&$data['start_min']>$data['limit']){
$this->errorMsg('起购数不能大于限购');
}
$this->model->goodsUpdate($dis,$data);
$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['specsForm']['specsItem'],$input['id']);
$res = $this->goodsSpePriceAdd($input['specsForm']['specsTable'],$input['id'],$spe_arr);
if($data['is_parameter']==1 && empty($input['parameter'])){
return $this->error('请添加商品参数');
}
//会员折扣
$discount_model->goodsAdd($discount_data,$this->_uniacid,$input['id']);
Db::commit();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-10-21 11:21
* @功能说明:分类详情
*/
public function goodsInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
//会员折扣模型
$discount_model = new DiscountGoods();
$res['goods_info'] = $this->model->dataInfo($dis);
$res['spe_info'] = $this->goodsSpeList($input['id']);
//会员商品信息
$res['memberForm']['is_discount'] = $res['goods_info']['is_discount'];
//商品折扣信息
$res['memberForm']['discount_data'] = $discount_model->goodsDiscount($input['id']);
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->goodsUpdateStatus($data,$input['id']);
return $this->success($res);
}
/**
* @param $data
* @param $goods_id
* @return array
* 添加多规格
*/
public function goodsSpeAdd($data,$goods_id){
/**
* 循环判断是否存在多个规格名添加图片的问题
* @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){
$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) {
$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;
}
}
}
}
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;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,175 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use app\farm\model\LandList;
use app\farm\model\Massif;
use app\farm\server\Land;
use think\App;
use think\facade\Db;
class AdminMassif extends AdminRest
{
protected $model;
protected $massif_model;
protected $land_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->massif_model = new Massif();
$this->land_model = new LandList();
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:43
* @功能说明:地块列表
*/
public function massifList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$data = $this->massif_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:43
* @功能说明:地块列表下拉框
*/
public function massifSelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$data = $this->massif_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:49
* @功能说明:添加地块
*/
public function massifAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$data = $this->massif_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:50
* @功能说明:编辑地块
*/
public function massifUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
//删除
if(isset($input['status'])&&$input['status']==-1){
$find = $this->land_model->landSomeFind($input['id'],1);
if($find==1){
$this->errorMsg('该地块服务正在被使用');
}
}
$data = $this->massif_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:50
* @功能说明:地块详情
*/
public function massifInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->massif_model->dataInfo($dis);
return $this->success($data);
}
}

View File

@@ -0,0 +1,451 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\ApiRest;
use app\farm\model\Config;
use app\farm\model\Coupon;
use app\farm\model\CouponRecord;
use app\farm\model\ShopOrder;
use app\farm\model\ShopOrderGoods;
use app\farm\model\ShopRefund;
use app\farm\model\Goods;
use app\farm\model\MsgConfig;
use app\farm\model\Order;
use app\farm\model\OrderAddress;
use app\farm\model\OrderGoods;
use app\farm\model\RefundOrder;
use app\farm\model\SystemInfo;
use app\shfarmop\model\User;
use longbingcore\wxcore\PushMsgModel;
use think\App;
use think\facade\Db;
use think\Request;
class AdminOrder extends AdminRest
{
protected $model;
protected $refund_model;
protected $order_goods_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new ShopOrder();
$this->refund_model = new ShopRefund();
$this->order_goods_model = new ShopOrderGoods();
autoCancelOrder($this->_uniacid);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:48
* @功能说明:个人中心
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['goods_name'])){
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
}
if(!empty($input['order_code'])){
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
}
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.store_id','=',$input['store_id']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->model->adminDataList($dis,$input['limit']);
$arr = [
//未支付
'no_pay_count' => 1,
//未发货
'no_send_count' => 2,
//已经发货
'have_send_count'=> 3
];
foreach ($arr as $ks=>$vs){
$map = [
'pay_type'=> $vs
];
$data[$ks] = $this->model->where($map)->count();
}
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']);
$data['hx_time'] = date('Y-m-d H:i:s',$data['hx_time']);
//剩余可申请退款数量
$can_refund_num = array_sum(array_column($data['order_goods'],'can_refund_num'));
//是否可以申请退款
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];
$where = [];
if(!empty($input['order_code'])){
$where[] = ['a.order_code','like','%'.$input['order_code'].'%'];
$where[] = ['d.order_code','like','%'.$input['order_code'].'%'];
}
if(!empty($input['goods_name'])){
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
}
// if(!empty($input['order_code'])){
//
// $dis[] = ['d.order_code','like','%'.$input['order_code'].'%'];
//
// }
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}else{
$dis[] = ['a.status','>',-1];
}
$data = $this->refund_model->indexDataList($dis,$where,$input['limit']);
$map = [
'status' => 1,
// 'user_id'=> $this->getUserId()
];
//退款中数量
$data['ing_count'] = $this->refund_model->where($map)->count();
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']);
$order_model = new ShopOrder();
$data['pay_order_code'] = $order_model->where(['id'=>$data['order_id']])->value('order_code');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 17:14
* @功能说明:楼长核销订单
*/
public function endOrder(){
$input = $this->_input;
$order_model= new ShopOrder();
$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 ShopRefund();
//判断有无申请中的退款订单
$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);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 09:21
* @功能说明:拒绝退款
*/
public function noPassRefund(){
$input = $this->_input;
$refund_order_model = new ShopRefund();
$res = $refund_order_model->noPassRefund($input['id'],$this->_user['id'],1);
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;
$refund_order_model = new ShopRefund();
$res = $refund_order_model->passOrder($input['id'],$input['price'],$this->payConfig(),$this->_user['id'],$input['text'],1);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-03-07 11:08
* @功能说明:地主商城订单发货
*/
public function shopOrderSend(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$order_model = new ShopOrder();
$order = $order_model->dataInfo($dis);
if(empty($order)||$order['pay_type']!=2){
$this->errorMsg('订单状态错误');
}
$refund_model = new ShopRefund();
//判断有无申请中的退款订单
$refund_order = $refund_model->dataInfo(['order_id'=>$input['id'],'status'=>1]);
if(!empty($refund_order)){
$this->errorMsg('该订单正在申请退款,请先处理再核销');
}
$config_model = new Config();
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
$update = [
'pay_type' => 3,
// 'express_company' => $input['express_company'],
//
// 'express_code' => $input['express_code'],
//
// 'express_mobile' => $input['express_mobile'],
//
// 'express_user' => $input['express_user'],
'send_time' => time(),
'hx_over_time' => time()+$config['auto_hx_time']*86400,
];
$data = $order_model->dataUpdate($dis,$update);
// $water_model = new FinanceWater();
// //商城订单农场主获得运费
// $water_model->addWater($order['id'],16,1,0);
$order = $order_model->dataInfo($dis);
$order_model->sendOrderService($order);
$sys_model = new PushMsgModel($order['uniacid']);
$sys_model->sendMsg($order,4);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 15:27
* @功能说明:上传视频
*/
public function uploadVideo(){
$input = $this->_input;
$res = $this->model->dataUpdate(['id'=>$input['id']],['video'=>$input['video']]);
return $this->success($res);
}
}

View File

@@ -0,0 +1,436 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\ClaimOrder;
use app\farm\model\Farmer;
use app\farm\model\FinanceWater;
use app\farm\model\LandCateText;
use app\farm\model\LandOrder;
use app\farm\model\Machine;
use app\farm\model\Monitor;
use app\farm\model\SendOrder;
use app\farm\model\User;
use app\farm\model\LandCate;
use app\farm\model\Wallet;
use app\shop\model\DistributionCash;
use app\shop\model\DistributionList;
use app\shop\model\StoreGoods;
use longbingcore\wxcore\PospalApi;
use longbingcore\wxcore\WxPay;
use longbingcore\wxcore\YsCloudApi;
use think\App;
use app\farm\model\Farmer as Model;
use think\facade\Db;
class AdminReseller extends AdminRest
{
protected $model;
protected $user_model;
protected $cash_model;
protected $wallet_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new DistributionList();
$this->cash_model = new DistributionCash();
$this->user_model = new User();
$this->wallet_model = new Wallet();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:列表
*/
public function resellerList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}else{
$dis[] = ['a.status','>',-1];
}
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"];
}
$where = [];
if(!empty($input['name'])){
$where[] = ['a.user_name','like','%'.$input['name'].'%'];
$where[] = ['a.mobile','like','%'.$input['name'].'%'];
}
$data = $this->model->adminDataList($dis,$input['limit'],$where);
$list = [
0=>'all',
1=>'ing',
2=>'pass',
4=>'nopass'
];
foreach ($list as $k=> $value){
$dis_s = [];
$dis_s[] =['uniacid','=',$this->_uniacid];
if(!empty($k)){
$dis_s[] = ['status','=',$k];
}else{
$dis_s[] = ['status','>',-1];
}
$data[$value] = $this->model->where($dis_s)->count();
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 10:17
* @功能说明:用户管理列表
*/
public function userRelationshipList(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid,
'is_fx' => 1
];
$data = $this->user_model->where($dis)->field('id,avatarUrl,nickName,pid,fx_bind_time,fx_cash')->order('fx_bind_time')->paginate($input['limit'])->toArray();
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['top_info'] = $this->user_model->where(['id'=>$v['pid'],'is_fx'=>1])->field('nickName,avatarUrl')->find();
//产生收益
$v['total_fx_cash'] = $this->cash_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('cash');
//累计提现
$v['wallte_cash'] = $this->wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('pay_price');
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 10:49
* @功能说明:分销关系查找
*/
public function userRelationshipListFind(){
$input = $this->_param;
$dis = [
'is_fx' => 1
];
if($input['type']==1){
//自己
$dis['id'] = $input['user_id'];
}elseif ($input['type']==2){
//下级
$dis['pid'] = $input['user_id'];
}else{
//上级
$top_id = $this->user_model->where(['id'=>$input['user_id'],'is_fx'=>1])->value('pid');
$dis['id'] = $top_id;
}
$data = $this->user_model->where($dis)->field('id,avatarUrl,nickName,pid,fx_bind_time,fx_cash')->order('fx_bind_time')->paginate($input['limit'])->toArray();
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
//产生收益
$v['total_fx_cash'] = $this->cash_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('cash');
//累计提现
$v['wallte_cash'] = $this->wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('pay_price');
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:58
* @功能说明:分销商详情
*/
public function resellerInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
$user_model = new User();
$data['nickName'] = $user_model->where(['id'=>$data['user_id']])->value('nickName');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-03 00:15
* @功能说明:审核(2通过,3取消,4拒绝)
*/
public function resellerUpdate(){
$input = $this->_input;
$diss = [
'id' => $input['id']
];
$info = $this->model->dataInfo($diss);
if(!empty($input['status'])&&in_array($input['status'],[2,4,-1])){
$input['sh_time'] = time();
if($input['status']==-1){
$fx_cash = $this->user_model->where(['id'=>$info['user_id']])->sum('fx_cash');
if($fx_cash>0){
$this->errorMsg('分销商还有佣金未提现');
}
$dis = [
'user_id' => $info['user_id'],
'status' => 1
];
$cash = $this->cash_model->dataInfo($dis);
if(!empty($cash)){
$this->errorMsg('分销商还有佣金未到账');
}
$dis['type'] = 5;
$wallet = $this->wallet_model->dataInfo($dis);
if(!empty($wallet)){
$this->errorMsg('分销商还有提现未处理');
}
}
}
$data = $this->model->dataUpdate($diss,$input);
if(isset($input['status'])){
$update = [
'is_fx' => 0
];
if($input['status']==2){
$update['fx_bind_time'] = time();
// $update['pid'] = $info['pid'];
$update['is_fx'] = 1;
}
$this->user_model->dataUpdate(['id'=>$info['user_id']],$update);
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 11:30
* @功能说明:分销佣金详情
*/
public function cashList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}else{
$dis[] = ['a.status','>',-1];
}
$where = [];
if(!empty($input['name'])){
$where[] = ['b.user_name','like','%'.$input['name'].'%'];
$where[] = ['c.nickName','like','%'.$input['name'].'%'];
}
$data = $this->cash_model->adminCashList($dis,$where,$input['limit']);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['source_info'] = $this->user_model->where(['id'=>$v['source_id']])->field('nickName,avatarUrl')->find();
$v['order_price'] = array_sum(array_column($v['order_goods'],'pay_price'));
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-29 14:48
* @功能说明:用户收益列表
*/
public function userProfitList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$where = [];
if(!empty($input['name'])){
$where[] = ['a.nickName','like','%'.$input['name'].'%'];
$where[] = ['b.user_name','like','%'.$input['name'].'%'];
}
$data = $this->model->userProfitList($dis,$input['limit'],$where);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
//产生收益
$v['total_fx_cash'] = $this->cash_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('cash');
//未入账
$v['unrecorded_fx_cash'] = $this->cash_model->where(['user_id'=>$v['id']])->where('status','in',[1])->sum('cash');
//累计提现
$v['total_wallte_cash'] = $this->wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1,2])->sum('pay_price');
//提现中
$v['wallte_ing_cash'] = $this->wallet_model->where(['user_id'=>$v['id']])->where('status','in',[1])->sum('pay_price');
}
}
return $this->success($data);
}
}

View File

@@ -0,0 +1,218 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use app\farm\model\LandList;
use app\farm\model\Massif;
use app\farm\model\Seed;
use app\farm\server\Land;
use think\App;
use think\facade\Db;
class AdminSeed extends AdminRest
{
protected $model;
protected $massif_model;
protected $land_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->massif_model = new Massif();
$this->land_model = new LandList();
}
/**
* @author chenniang
* @DataTime: 2021-12-20 16:54
* @功能说明:种子列表
*/
public function seedList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$seed_model = new Seed();
$data = $seed_model->dataList($dis,$input['limit']);
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: 2021-12-20 16:54
* @功能说明:种子列表
*/
public function seedSelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$seed_model = new Seed();
$data = $seed_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-20 16:57
* @功能说明:添加种子
*/
public function seedAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$seed_model = new Seed();
$data = $seed_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:50
* @功能说明:编辑种子
*/
public function seedUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$seed_model = new Seed();
//删除
if(isset($input['status'])&&in_array($input['status'],[-1,0])){
$find = $this->land_model->landSomeFind($input['id'],2);
if($find==1){
$this->errorMsg('该种子正在被使用');
}
}
$data = $seed_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:50
* @功能说明:编辑种子
*/
public function seedInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$seed_model = new Seed();
$data = $seed_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 14:50
* @功能说明:编辑种子
*/
public function seedStatusUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$seed_model = new Seed();
$data = $seed_model->where($dis)->update($input);
return $this->success($data);
}
}

View File

@@ -0,0 +1,861 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\AboutUs;
use app\farm\model\SendConfig;
use app\farm\model\WelfareColumn;
use app\restaurant\model\Table;
use app\farm\model\Article;
use app\farm\model\Banner;
use app\shop\model\MsgConfig;
use app\farm\model\PayConfig;
use think\App;
use app\farm\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
];
if(!empty($input['app_banner'])){
$input['app_banner'] = implode(',',$input['app_banner']);
}
$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];
if(!empty($input['type'])){
$dis[] = ['type','=',$input['type']];
}
$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();
$input['uniacid'] = $this->_uniacid;
$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')->order('top desc,id desc')->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(isset($input['cert_path'])&&isset($input['key_path'])){
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\farm\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);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 11:58
* @功能说明:桌号列表
*/
public function tableList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$table_model = new Table();
$data = $table_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:21
* @功能说明:添加桌号
*/
public function tableAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$table_model = new Table();
$res = $table_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:23
* @功能说明:编辑桌号
*/
public function tableUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$table_model = new Table();
$res = $table_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:23
* @功能说明:桌号详情
*/
public function tableInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$table_model = new Table();
$res = $table_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-09 15:15
* @功能说明:刷新桌号码
*/
public function reTableQr(){
$input = $this->_input;
$qr_insert = [
'id' => $input['id']
];
$table_model = new Table();
$qr = $table_model->orderQr($qr_insert,$this->_uniacid);
if(!empty($qr)){
$table_model->dataUpdate(['id'=>$input['id']],['qr'=>$qr]);
}
return $this->success($qr);
}
/**
* @author chenniang
* @DataTime: 2021-12-30 11:51
* @功能说明:关于我们列表
*/
public function aboutUsList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$dis[] = ['type','=',0];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$us_model = new AboutUs();
$data = $us_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:21
* @功能说明:添加我们列表
*/
public function aboutUsAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$us_model = new AboutUs();
$res = $us_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:23
* @功能说明:编辑我们列表
*/
public function aboutUsUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$us_model = new AboutUs();
$res = $us_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:23
* @功能说明:我们列表详情
*/
public function aboutUsInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id'],
];
$us_model = new AboutUs();
$res = $us_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-08 13:23
* @功能说明:我们列表详情
*/
public function aboutUsInfoType(){
$input = $this->_param;
$input['type'] = !empty($input['type'])?$input['type']:0;
$dis = [
'type'=> $input['type'],
'uniacid' => $this->_uniacid
];
$us_model = new AboutUs();
$res = $us_model->dataInfo($dis);
if(!empty($input['type'])&&empty($res)){
$title = $input['type']==1?'动物认养协议':'土地租赁协议';
$dis['title'] = $title;
$us_model->dataAdd($dis);
$res = $us_model->dataInfo($dis);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-01-11 10:48
* @功能说明:配送配置详情
*/
public function sendConfigInfo(){
$dis = [
'uniacid' => $this->_uniacid
];
$config = $this->model->dataInfo($dis);
$send_model = new SendConfig();
$send_config = $send_model->where($dis)->select()->toArray();
$config['send_time'] = $send_config;
return $this->success($config);
}
/**
* @author chenniang
* @DataTime: 2022-01-11 11:51
* @功能说明:编辑配送设置
*/
public function sendConfigUpdate(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid
];
$update = [
'app_day' => $input['app_day'],
// 'start_distance' => $input['start_distance'],
// 'start_price' => $input['start_price'],
//
// 'renew_distance' => $input['renew_distance'],
//
// 'renew_price' => $input['renew_price'],
];
$res = $this->model->dataUpdate($dis,$update);
$send_model = new SendConfig();
$send_model->where($dis)->delete();
if(!empty($input['send_time'])){
foreach ($input['send_time'] as $key => $value){
$input['send_time'][$key]['uniacid'] = $this->_uniacid;
}
$send_model->saveAll($input['send_time']);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:27
* @功能说明:公益栏目列表
*/
public function welfareList(){
$input = $this->_param;
$welfare_model = new WelfareColumn();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$type = !empty($input['type'])?$input['type']:1;
$dis[] = ['type','=',$type];
$data = $welfare_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:37
* @功能说明:添加公益栏目
*
*/
public function welfareAdd(){
$input = $this->_input;
$welfare_model = new WelfareColumn();
$input['uniacid'] = $this->_uniacid;
$res = $welfare_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:35
* @功能说明:编辑公益栏目
*/
public function welfareUpdate(){
$input = $this->_input;
$welfare_model = new WelfareColumn();
$dis = [
'id' => $input['id']
];
$res = $welfare_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:35
* @功能说明:公益栏目详情
*/
public function welfareInfo(){
$input = $this->_param;
$welfare_model = new WelfareColumn();
$dis = [
'id' => $input['id']
];
$res = $welfare_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,190 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use app\farm\model\LandList;
use app\farm\model\Massif;
use app\farm\model\Source;
use app\farm\server\Land;
use think\App;
use think\facade\Db;
class AdminSource extends AdminRest
{
protected $model;
protected $massif_model;
protected $land_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->massif_model = new Massif();
$this->land_model = new LandList();
}
/**
* @author chenniang
* @DataTime: 2021-12-14 17:04
* @功能说明:溯源列表
*/
public function sourceList(){
$input = $this->_param;
$source_model = new Source();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
$data = $source_model->dataList($dis,$input['limit']);
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: 2021-12-14 17:04
* @功能说明:溯源下拉框
*/
public function sourceSelect(){
$input = $this->_param;
$source_model = new Source();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
if(!empty($input['farmer_id'])){
$dis[] = ['farmer_id','=',$input['farmer_id']];
}
$data = $source_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 17:10
* @功能说明:添加溯源
*/
public function sourceAdd(){
$input = $this->_input;
$source_model = new Source();
$input['uniacid'] = $this->_uniacid;
$res = $source_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 17:12
* @功能说明:编辑溯源
*/
public function sourceUpdate(){
$input = $this->_input;
$source_model = new Source();
$input['uniacid'] = $this->_uniacid;
$dis = [
'id' => $input['id']
];
//删除
if(isset($input['status'])&&$input['status']==-1){
$find = $this->land_model->landSomeFind($input['id'],3);
if($find==1){
$this->errorMsg('该溯源正在被使用');
}
}
$res = $source_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-12-14 17:12
* @功能说明:编辑溯源
*/
public function sourceInfo(){
$input = $this->_param;
$source_model = new Source();
$dis = [
'id' => $input['id']
];
$res = $source_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,852 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\farm\model\AdminRole;
use app\farm\model\BalanceWater;
use app\farm\model\Evaluate;
use app\farm\model\FinanceWater;
use app\farm\model\Node;
use app\farm\model\Role;
use app\massage\controller\Admin;
use app\massage\model\CarUserTrophy;
use app\massage\model\Commission;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Date;
use app\massage\model\OrderGoods;
use app\massage\model\RefundOrder;
use app\shop\model\IntegralLog;
use app\shop\model\Wallet;
use think\App;
use app\farm\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();
}
/**
* @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[] = ['avatarUrl','=',''];
}else{
$dis[] = ['avatarUrl','<>',''];
}
}
if(isset($input['role'])){
$dis[] = ['role','=',$input['role']];
}
if(isset($input['is_black'])){
$dis[] = ['is_black','=',$input['is_black']];
}
$where = [];
if(!empty($input['nickName'])){
$where[] = ['nickName','like','%'.$input['nickName'].'%'];
$where[] = ['phone','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'],$where);
if(!empty($data['data'])){
$finance_model = new FinanceWater();
$water_model = new BalanceWater();
$inte_model = new IntegralLog();
foreach ($data['data'] as &$v){
$cash_data = $finance_model->getUserCashData($v['id']);
//总消费
$v['pay_cash'] = $cash_data['cash'];
//总退款
$v['refund_cash'] = $cash_data['refund_cash'];
//充值金额
$v['balance_cash']= $water_model->where(['type'=>1,'user_id'=>$v['id']])->sum('price');
//总积分
$v['total_integral'] = $inte_model->where(['user_id'=>$v['id']])->where('integral_add','>',0)->sum('integral_add');
//兑换积分
$v['pay_integral'] = round($v['total_integral']-$v['integral'],2);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 14:39
* @功能说明:编辑员工
*/
public function userUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-08-28 23:03
* @功能说明:佣金记录
*/
public function commList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}
if(!empty($input['top_name'])){
$dis[] = ['c.nickName','like','%'.$input['top_name'].'%'];
}
$comm_model = new Commission();
$data = $comm_model->recordList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 15:02
* @功能说明:用户所有获得的奖杯
*/
public function userTrophy(){
$input = $this->_param;
$user_trophy_model = new CarUserTrophy();
$dis = [
'a.user_id' => $input['user_id'],
'a.status' => 1,
'b.status' => 1
];
$data = $user_trophy_model->alias('a')
->join('shequshop_car_trophy b','a.trophy_id = b.id')
->where($dis)
->field('a.*,b.title,b.cover')
->select()
->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 15:04
* @功能说明:用户添加奖杯
*/
public function userTrophyAdd(){
$input = $this->_input;
$user_trophy_model = new CarUserTrophy();
foreach ($input['user_id'] as $value){
foreach ($input['trophy_id'] as $v){
$dis = [
'user_id' => $value,
'trophy_id'=> $v,
'uniacid' => $this->_uniacid
];
$find = $user_trophy_model->where($dis)->where('status','>',-1)->find();
//增加
if($input['add']==1){
if(empty($find)){
$user_trophy_model->dataAdd($dis);
}
}else{
//减少
if(!empty($find)){
$user_trophy_model->dataUpdate($dis,['status'=>-1]);
}
}
}
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-02-10 13:32
* @功能说明:评价管理
*/
public function evaluateList(){
$input = $this->_param;
$eva_model = new Evaluate();
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','>',-1];
if(!empty($input['type'])){
$dis[] = ['a.type','=',$input['type']];
}
if(!empty($input['good'])){
$dis[] = ['a.star','>=',3];
}
if(!empty($input['bad'])){
$dis[] = ['a.star','<',3];
}
if(!empty($input['farmer_id'])){
$dis[] = ['a.farmer_id','=',$input['farmer_id']];
}
if(!empty($input['title'])){
$dis[] = ['b.title','line',"%".$input['title'].'%'];
}
$data = $eva_model->adminList($dis,$input['limit']);
$where[] = ['uniacid','=',$this->_uniacid];
$where[] = ['status','>',-1];
if(!empty($input['type'])){
$where[] = ['type','=',$input['type']];
}
$data['good_eva'] = $eva_model->where($where)->where('star','>=',3)->count();
$data['bad_eva'] = $eva_model->where($where)->where('star','<',3)->count();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-02-10 13:45
* @功能说明:编辑评论
*/
public function evaluateUpdate(){
$input = $this->_input;
$eva_model = new Evaluate();
$dis = [
'id' => $input['id']
];
$data = $eva_model->dataInfo($dis);
$res = $eva_model->dataUpdate($dis,$input);
if(!empty($input['status'])&&$input['status']==-1){
//修改农场主的评分
$res = $eva_model->updateFarmerStar($data['farmer_id']);
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:02
* @功能说明:角色列表
*/
public function roleList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$role_model = new Role();
$data = $role_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:02
* @功能说明:角色列表
*/
public function roleSelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$role_model = new Role();
$data = $role_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 13:56
* @功能说明:添加角色
*/
public function roleAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$role_model = new Role();
$data = $role_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:17
* @功能说明:编辑角色
*/
public function roleUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$role_model = new Role();
//删除
if(isset($input['status'])&&$input['status']==-1){
$adminRole_mdoel = new AdminRole();
$find = $adminRole_mdoel->alias('a')
->join('lbfarm_school_admin b','a.admin_id = b.id')
->where(['a.role_id'=>$input['id']])
->where('b.status','>',-1)
->find();
if(!empty($find)){
$this->errorMsg('该角色正在被使用');
}
}
$data = $role_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:17
* @功能说明:角色详情
*/
public function roleInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$role_model = new Role();
$data = $role_model->dataInfo($dis);
$node_model = new Node();
$node = $node_model->where(['role_id'=>$input['id']])->select()->toArray();
if(!empty($node)){
foreach ($node as $k=>$v){
$node[$k]['auth'] = !empty($v['auth'])?explode(',',$v['auth']):[];
}
}
$data['node'] = $node;
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:18
* @功能说明:给账号分配角色(多选)
*/
public function adminRoleAdd(){
$input = $this->_input;
$adminRole_mdoel = new AdminRole();
$adminRole_mdoel->where(['admin_id'=>$input['admin_id']])->delete();
if(!empty($input['role'])){
foreach ($input['role'] as $key => $value){
$insert[$key] = [
'uniacid' => $this->_uniacid,
'admin_id'=> $input['admin_id'],
'role_id' => $value
];
}
$adminRole_mdoel->saveAll($insert);
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:24
* @功能说明:账号所匹配的角色详情
*/
public function adminInfo(){
$input = $this->_param;
$adminRole_mdoel = new AdminRole();
$admin_model = new \app\farm\model\Admin();
$dis= [
'id' => $input['id']
];
$data = $admin_model->dataInfo($dis);
$dis = [
'a.uniacid' => $this->_uniacid,
'b.status' => 1,
'a.admin_id'=> $input['id']
];
$data['role'] = $adminRole_mdoel->alias('a')
->join('lbfarm_role b','a.role_id = b.id')
->where($dis)
->field('b.*,a.role_id')
->group('b.id')
->select()
->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:24
* @功能说明:账号所匹配的角色的节点详情
*/
public function adminNodeInfo(){
$input = $this->_param;
$adminRole_mdoel = new AdminRole();
$data['is_admin'] = isset($this->_user['is_admin'])?$this->_user['is_admin']:1;
$dis = [
'a.uniacid' => $this->_uniacid,
'b.status' => 1,
'a.admin_id'=> $this->_user['id']
];
$data['node'] = $adminRole_mdoel->alias('a')
->join('lbfarm_role b','a.role_id = b.id')
->join('lbfarm_node c','c.role_id = b.id')
->where($dis)
->field('c.*')
->group('c.id')
->select()
->toArray();
if(!empty($data['node'])){
foreach ($data['node'] as $k=>$v){
$data['node'][$k]['auth'] = !empty($v['auth'])?explode(',',$v['auth']):[];
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:41
* @功能说明:账号列表
*/
public function adminList(){
$input = $this->_param;
$admin_model = new \app\farm\model\Admin();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['username','like','%'.$input['title'].'%'];
}
$data = $admin_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:47
* @功能说明:添加账号
*/
public function adminAdd(){
$input = $this->_input;
$admin_model = new \app\farm\model\Admin();
$dis = [
'uniacid' => $this->_uniacid,
'username'=> $input['username'],
];
$find = $admin_model->where($dis)->where('status','>',-1)->find();
if(!empty($find)){
$this->errorMsg('账号名不能重复');
}
$insert = [
'uniacid' => $this->_uniacid,
'username'=> $input['username'],
'o_passwd'=> $input['passwd'],
'passwd' => checkPass($input['passwd']),
'is_admin'=> 0,
];
$admin_model->dataAdd($insert);
$admin_id = $admin_model->getLastInsID();
$adminRole_mdoel = new AdminRole();
$adminRole_mdoel->where(['admin_id'=>$admin_id])->delete();
if(!empty($input['role'])){
foreach ($input['role'] as $key => $value){
$inserts[$key] = [
'uniacid' => $this->_uniacid,
'admin_id'=> $admin_id,
'role_id' => $value
];
}
$adminRole_mdoel->saveAll($inserts);
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-01-04 14:47
* @功能说明:添加账号
*/
public function adminUpdate(){
$input = $this->_input;
$admin_model = new \app\farm\model\Admin();
if(!empty($input['username'])){
$dis = [
'uniacid' => $this->_uniacid,
'username'=> $input['username'],
];
$find = $admin_model->where($dis)->where('status','>',-1)->where('id','<>',$input['id'])->find();
if(!empty($find)){
$this->errorMsg('账号名不能重复');
}
}
if(!empty($input['passwd'])){
$input['o_passwd'] = $input['passwd'];
$input['passwd'] = checkPass($input['passwd']);
}
$dis = [
'id' => $input['id']
];
if(isset($input['role'])){
$role = $input['role'];
unset($input['role']);
}
$admin_model->dataUpdate($dis,$input);
$adminRole_mdoel = new AdminRole();
$adminRole_mdoel->where(['admin_id'=>$input['id']])->delete();
if(!empty($role)){
foreach ($role as $key => $value){
$inserts[$key] = [
'uniacid' => $this->_uniacid,
'admin_id'=> $input['id'],
'role_id' => $value
];
}
$adminRole_mdoel->saveAll($inserts);
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-07-20 16:00
* @功能说明:修改用户积分
*/
public function userIntegralUpdate(){
$input = $this->_input;
$log_model = new IntegralLog();
$type = $input['integral']>0?12:13;
$res = $log_model->integralUserAdd($input['user_id'],$input['integral'],$this->_uniacid,2,$type);
return $this->success($res);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,263 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\BalanceCard;
use app\farm\model\BalanceOrder;
use app\farm\model\BalanceWater;
use app\farm\model\User;
use app\Rest;
use app\shop\controller\IndexWxPay;
use longbingcore\wxcore\PayModel;
use think\App;
use think\Request;
class IndexBalance extends ApiRest
{
protected $model;
protected $article_model;
protected $coach_model;
protected $water_model;
protected $app;
public function __construct(App $app) {
parent::__construct($app);
$this->app = $app;
$this->model = new BalanceCard();
$this->balance_order = new BalanceOrder();
$this->water_model = new BalanceWater();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值充值卡列表
*/
public function cardList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 17:00
* @功能说明:充值余额
*/
public function payBalanceOrder(){
$input = $this->_input;
if(!empty($input['card_id'])){
$dis = [
'id' => $input['card_id'],
'status' => 1
];
$card = $this->model->dataInfo($dis);
if(empty($card)){
$this->errorMsg('充值卡已被下架');
}
}else{
$card = [
'price' => $input['price'],
'true_price' => $input['price'],
'id' => 0,
'integral' => 0,
'member_level'=> 0,
'title' => '自定义金额充值'
];
}
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'order_code' => orderCode(),
'pay_price' => $card['price'],
'sale_price' => $card['price'],
'true_price' => $card['true_price'],
'card_id' => $card['id'],
'title' => $card['title'],
'integral' => $card['integral'],
'pay_model' => $input['pay_model'],
'member_level'=> $card['member_level'],
//
// 'phone' => $input['phone']
];
$res = $this->balance_order->dataAdd($insert);
if($res==0){
$this->errorMsg('充值失败');
}
if($input['pay_model']==3){
$pay_model = new PayModel($this->payConfig());
$jsApiParameters = $pay_model->aliPay($insert['order_code'],$insert['pay_price'],'余额充值');
$arr['pay_list']= $jsApiParameters;
$arr['order_code']= $insert['order_code'];
}else{
//微信支付
$pay_controller = new IndexWxPay($this->app);
//支付
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"储值",['type' => 'Balance' , 'out_trade_no' => $insert['order_code']],$insert['pay_price']);
$arr['pay_list']= $jsApiParameters;
}
return $this->success($arr);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 17:34
* @功能说明:充值订单列表
*/
public function balaceOrder(){
$input = $this->_param;
$dis[] = ['status','=',2];
$dis[] = ['user_id','=',$this->getUserId()];
if(!empty($input['start_time'])){
$dis[] = ['pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->balance_order->dataList($dis);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
$v['pay_time'] = date('Y-m-d H:i:s',$v['pay_time']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 18:00
* @功能说明:消费明细
*/
public function payWater(){
$input = $this->_param;
$dis[] = ['user_id','=',$this->getUserId()];
// $dis[] = ['type','=',2];
if(!empty($input['start_time'])){
$dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->water_model->dataList($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);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,187 @@
<?php
namespace app\farm\controller;
use app\AdminRest;
use app\ApiRest;
use app\farm\model\BagAtv;
use app\farm\model\Coupon;
use app\farm\model\CouponAtv;
use app\farm\model\CouponAtvRecord;
use app\farm\model\CouponRecord;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class IndexCoupon extends ApiRest
{
protected $model;
protected $atv_model;
protected $record_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Coupon();
$this->atv_model = new BagAtv();
$this->record_model = new CouponRecord();
}
/**
* @author chenniang
* @DataTime: 2022-03-02 11:07
* @功能说明:正在进行中的福包活动
*/
public function bagIngInfo(){
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
$dis[] = ['start_time','<',time()];
$dis[] = ['end_time','>',time()];
$data = $this->atv_model->dataInfo($dis);
if(empty($data)){
$this->errorMsg('活动已结束');
}
$where = [
'atv_id' => $data['id'],
'user_id'=> $this->getUserId(),
'status' => 1
];
//查看自己是否领取过
$user_record = $this->record_model->dataInfo($where);
if(!empty($user_record)){
//已经领取
$data['active_status'] = 2;
}elseif ($data['user_num']<$data['have_num']){
//已经领完
$data['active_status'] = 3;
}else{
//进行中
$data['active_status'] = 1;
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-02 13:44
* @功能说明:新客户获取活动优惠券
*/
public function getAtvCoupon(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$data = $this->atv_model->dataInfo($dis);
if(empty($data)){
$this->errorMsg('活动已结束');
}
$where = [
'atv_id' => $data['id'],
'user_id'=> $this->getUserId(),
'status' => 1
];
//查看自己是否领取过
$user_record = $this->record_model->dataInfo($where);
if(empty($user_record)){
$this->errorMsg('你已经领取过了');
}
//添加领取记录
Db::startTrans();
$insert = [
'uniacid' => $this->_uniacid,
'get_user' => $this->getUserId(),
'share_user'=> $input['share_user'],
'atv_id' => $data['id'],
'user_coupon'=> $data['user_coupon'],
'user_coupon_num'=> $data['user_coupon_num'],
'share_coupon'=> $data['share_coupon'],
];
$res = $this->record_model->dataAdd($insert);
if($res==0){
Db::rollback();
$this->errorMsg('领取失败');
}
$id = $this->record_model->getLastInsID();
$coupon_record_model = new CouponRecord();
//给新客户发优惠券
$res = $coupon_record_model->recordAdd($data['user_coupon'],$insert['get_user'],$id);
if(!empty($res['code'])){
Db::rollback();
$this->errorMsg($res['msg']);
}
Db::commit();
return $this->success($res);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,441 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\Farmer;
use app\farm\model\ShopGoods;
use app\farm\model\ShopGoodsCate;
use app\Rest;
use app\farm\model\Cap;
use app\farm\model\Car;
use app\farm\model\Goods;
use app\farm\model\GoodsCate;
use app\farm\model\User;
use app\shop\model\GoodsSpe;
use app\shop\model\GoodsSpePrice;
use app\shop\model\IntegralList;
use app\shop\model\OrderGoods;
use app\shop\model\SeckillList;
use app\shop\model\ShopGoodsSpe;
use app\shop\model\StoreGoods;
use think\App;
use think\Request;
class IndexGoods extends ApiRest
{
protected $model;
protected $cate_model;
protected $car_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new ShopGoods();
$this->cate_model = new ShopGoodsCate();
$this->car_model = new Car();
}
/**
* @author chenniang
* @DataTime: 2021-03-19 11:57
* @功能说明:首页选择店铺列表
*/
public function indexStoreList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',2];
$dis[] = ['business_status','=',1];
if(!empty($input['store_name'])){
$dis[] = ['title','like','%'.$input['store_name'].'%'];
}
$lat = !empty($input['lat'])?$input['lat']:0;
$lng = !empty($input['lng'])?$input['lng']:0;
$alh = '(2 * 6378.137* ASIN(SQRT(POW(SIN(3.1415926535898*('.$lat.'-lat)/360),2)+COS(3.1415926535898*'.$lat.'/180)* COS('.$lat.' * 3.1415926535898/180)*POW(SIN(3.1415926535898*('.$lng.'-lng)/360),2))))*1000 as distance';
$alhs = '(2 * 6378.137* ASIN(SQRT(POW(SIN(3.1415926535898*('.$lat.'-lat)/360),2)+COS(3.1415926535898*'.$lat.'/180)* COS('.$lat.' * 3.1415926535898/180)*POW(SIN(3.1415926535898*('.$lng.'-lng)/360),2))))*1000<20000';
$store_model = new Farmer();
$data = $store_model->dataDistanceList($dis,$alh,$alhs,10);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['distance'] = getDistances($v['lng'],$v['lat'],$lng,$lat);
$v['distance'] = $store_model->getDistanceAttr($v['distance']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:24
* @功能说明:选择门店
*/
public function selectStore(){
$input = $this->_input;
$user_model = new User();
$res = $user_model->dataUpdate(['id'=>$this->getUserId()],['last_store_id'=>$input['store_id']]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 16:46
* @功能说明:分类列表
*/
public function goodsIndex(){
$input = $this->_param;
$store_id = !empty($input['store_id'])?$input['store_id']:0;
$data['cate_id'] = $this->cate_model->shopCateList($this->_uniacid,$store_id);
if(!empty($store_id)){
$store_model = new Farmer();
$data['store_info'] = $store_model->dataInfo(['id'=>$store_id]);
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 13:47
* @功能说明:
*/
public function haveSelectStoreId(){
return $this->success($this->getStoreInfo()['id']);
}
/**
* @author chenniang
* @DataTime: 2022-02-22 15:27
* @功能说明:商品列表
*/
public function goodsList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','=',1];
// $dis[] = ['a.index_show','=',1];
$dis[] = ['d.status','=',2];
$dis[] = ['d.business_status','=',1];
if(!empty($input['store_id'])){
$dis[] = ['b.store_id','=',$input['store_id']];
}
if(!empty($input['cate_id'])){
$dis[] = ['c.cate_id','=',$input['cate_id']];
}
if(!empty($input['goods_name'])){
$dis[] = ['a.goods_name','like','%'.$input['goods_name'].'%'];
}
//商品信息
$data = $this->model->indexGoodsList($dis,10);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$where = [
'type' => 5,
'user_id' => $this->getUserId()
];
$v['car_count'] = $this->car_model->where($where)->count();
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:46
* @功能说明:商品详情
*/
public function goodsInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
$farm_model = new Farmer();
$where[] = ['id','in',$data['store']];
$data['store_info'] = $farm_model->dataInfo($where);
$spe_model = new ShopGoodsSpe();
$spe_price_model = new GoodsSpePrice();
$where = [
'goods_id' => $input['id'],
'status' => 1
];
$data['spe_text'] = $spe_model->goodsSpe($where);
$data['spe_price'] = $spe_price_model->goodsSpePrice($where);
$kill_model = new SeckillList();
$integral_model = new IntegralList();
//秒杀活动
$data['kill_list'] = $kill_model->atvIng($input['id'],0,2);
if(!empty($data['spe_price'])){
foreach ($data['spe_price'] as &$v){
//查询是否有秒杀活动
$v['kill_atv'] = $kill_model->atvIng($input['id'],$v['id']);
if(empty($v['kill_atv'])){
//积分活动
$v['integral_atv'] = $integral_model->atvIng($input['id'],$v['id']);
}else{
$v['integral_atv'] = [];
}
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:07
* @功能说明:购物车信息
*/
public function carInfo(){
$input = $this->_param;
$store_id = !empty($input['store_id'])?$input['store_id']:0;
//购物车信息
$car_info = $this->car_model->carPriceAndCount($this->getUserId(),$store_id,1);
return $this->success($car_info);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:46
* @功能说明:添加到购物车
*/
public function addCar(){
$input = $this->_input;
$is_show_del = !empty($input['is_show_del'])?$input['is_show_del']:1;
if($is_show_del==1){
$this->car_model->where(['user_id'=>$this->getUserId(),'is_show'=>2])->delete();
}
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'farmer_id'=> $input['store_id'],
'goods_id'=> $input['goods_id'],
'spe_id' => $input['spe_id'],
'type' => 5,
'is_show' => !empty($input['is_show'])?$input['is_show']:1,
];
$input['goods_num'] = !empty($input['goods_num'])?$input['goods_num']:1;
$info = $this->car_model->dataInfo($insert);
//增加数量
if(!empty($info)){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']+$input['goods_num']]);
}else{
//添加到购物车
$insert['goods_num'] = $input['goods_num'];
$insert['status'] = 1;
$res = $this->car_model->dataAdd($insert);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:54
* @功能说明:删除购物车
*/
public function delCar(){
$input = $this->_input;
$info = $this->car_model->dataInfo(['id'=>$input['id']]);
$input['goods_num'] = !empty($input['goods_num'])?$input['goods_num']:1;
//加少数量
if($info['goods_num']>$input['goods_num']){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']-$input['goods_num']]);
}else{
$res = $this->car_model->where(['id'=>$info['id']])->delete();
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 10:39
* @功能说明:
*/
public function carUpdate(){
$input = $this->_input;
if(!empty($input['id'])){
$res = $this->car_model->where('id','in',$input['id'])->update(['status'=>$input['status']]);
}else{
$res = $this->car_model->where('user_id','=',$this->getUserId())->update(['status'=>$input['status']]);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:59
* @功能说明:批量删除购物车
*/
public function delSomeCar(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'farmer_id'=> $this->getStoreInfo()['id'],
'type' => 5,
];
$res = $this->car_model->where($dis)->delete();
return $this->success($res);
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\Config;
use app\farm\model\FinanceWater;
use app\farm\model\InfoRecord;
use app\farm\model\SystemInfo;
use app\farm\model\User;
use app\farm\model\Wallet;
use app\farm\model\WelfareColumn;
use app\shop\model\DistributionCash;
use app\shop\model\DistributionList;
use think\App;
use think\facade\Db;
use think\Request;
class IndexInfo extends ApiRest
{
protected $model;
protected $user_model;
protected $cash_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new SystemInfo();
$this->info_model = new WelfareColumn();
$this->record_model = new InfoRecord();
}
/**
* @author chenniang
* @DataTime: 2022-08-22 15:13
* @功能说明:查看自己的系统公告
*/
public function systemInfoList(){
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['user_id','=',$this->getUserId()];
$count = $this->model->where($dis)->where(['status'=>0])->count();
$this->model->where($dis)->where(['status'=>0])->update(['status'=>1]);
$dis[] = ['status','>',-1];
$data = $this->model->dataList($dis);
$data['no_read_count'] = $count;
$data['operate_no_read_count'] = $this->record_model->noReadCount($this->getUserId(),$this->_uniacid);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-08-22 15:54
* @功能说明:运营公告
*/
public function operateInfoList(){
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['type','=',3];
$dis[] = ['status','=',1];
$data = $this->info_model->dataList($dis);
//未读消息数量
$data['operate_no_read_count'] = $this->record_model->noReadCount($this->getUserId(),$this->_uniacid);
$where[] = ['uniacid','=',$this->_uniacid];
$where[] = ['user_id','=',$this->getUserId()];
$data['no_read_count'] = $this->model->where($where)->where(['status'=>0])->count();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-08-22 16:16
* @功能说明:运营公告详情
*/
public function operateInfoInfo(){
$input = $this->_param;
$data = $this->info_model->dataInfo(['id'=>$input['id']]);
$insert = [
'user_id' => $this->getUserId(),
'uniacid' => $this->_uniacid,
'info_id' => $input['id']
];
$find = $this->record_model->dataInfo($insert);
if(empty($find)){
$this->record_model->dataAdd($insert);
}
return $this->success($data);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,959 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\Coupon;
use app\farm\model\CouponRecord;
use app\farm\model\Evaluate;
use app\farm\model\Farmer;
use app\farm\model\ShopOrder;
use app\farm\model\ShopOrderGoods;
use app\farm\model\ShopRefund;
use app\publics\model\TmplConfig;
use app\farm\model\Address;
use app\farm\model\Car;
use app\farm\model\Config;
use app\farm\model\Goods;
use app\farm\model\MsgConfig;
use app\farm\model\Order;
use app\farm\model\OrderAddress;
use app\farm\model\OrderGoods;
use app\farm\model\RefundOrder;
use app\shfarmop\model\User;
use app\shop\controller\IndexWxPay;
use app\shop\model\SeckillList;
use longbingcore\wxcore\PayModel;
use think\App;
use think\facade\Db;
use think\Request;
class IndexOrder extends ApiRest
{
protected $model;
protected $refund_model;
protected $order_goods_model;
protected $app;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new ShopOrder();
$this->app = $app;
$this->refund_model = new ShopRefund();
$this->order_goods_model = new ShopOrderGoods();
autoCancelOrder($this->_uniacid);
}
/**
* @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);
$eva_model = new Evaluate();
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;
}
$dis = [
'user_id' => $this->getUserId(),
'order_id'=> $v['id'],
'type' => 3
];
$have_eva = $eva_model->where($dis)->where('status','>',-1)->find();
//是否已经评价
$v['have_eva'] = !empty($have_eva)?1:0;
}
}
$arr = [
//未支付
'no_pay_count' => 1,
//未发货
'no_send_count' => 2,
//已经发货
'have_send_count'=> 3
];
foreach ($arr as $ks=>$vs){
$map = [
'user_id' => $this->getUserId(),
'pay_type'=> $vs
];
$data[$ks] = $this->model->where($map)->count();
}
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();
$time_arr = ['create_time','pay_time','end_time','hx_time','cancel_time'];
foreach ($time_arr as $v){
$data[$v] = !empty($data[$v])?date('Y-m-d H:i:s',$data[$v]):$data[$v];
}
$data['distance'] = distance_text($data['distance']);
$end_time = date('H:i',$data['send_end_time'])=='00:00'?'24:00':date('H:i',$data['send_end_time']);
//配送时间
$data['user_send_time'] = date('Y-m-d H:i',$data['send_start_time']).'~'.$end_time;
//剩余可申请退款数量
$can_refund_num = array_sum(array_column($data['order_goods'],'can_refund_num'));
//是否可以申请退款
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;
}
$farmer_model = new Farmer();
$data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']],'title');
$dis = [
'user_id' => $this->getUserId(),
'order_id'=> $data['id'],
'type' => 3
];
$eva_model = new Evaluate();
$have_eva = $eva_model->where($dis)->where('status','>',-1)->find();
//是否已经评价
$data['have_eva'] = !empty($have_eva)?1: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);
$map = [
'status' => 1,
'user_id'=> $this->getUserId()
];
//退款中数量
$data['ing_count'] = $this->refund_model->where($map)->count();
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;
$coupon_id = isset($input['coupon_id'])?$input['coupon_id']:0;
$is_show = isset($input['is_show'])?$input['is_show']:1;
$send_type = isset($input['send_type'])?$input['send_type']:2;
$no_i = isset($input['no_i'])?$input['no_i']:1;
$address_model = new Address();
$defult_address = $address_model->dataInfo(['user_id'=>$this->getUserId(),'status'=>1]);
$defult_address_id = !empty($defult_address)?$defult_address['id']:0;
$address_id = !empty($input['address_id'])?$input['address_id']:$defult_address_id;
$order_info = $this->model->payOrderInfo($this->getUserId(),0,$coupon_id,$address_id,$is_show,$send_type,$no_i);
if(!empty($input['address_id'])){
//默认地址
$order_info['address'] = $address_model->dataInfo(['id'=>$input['address_id']]);
}else{
$order_info['address'] = $defult_address;
}
$coupon_modle = new Coupon();
$coupon_record_model = new CouponRecord();
//可用优惠券数量
$canUseCoupon = $coupon_modle->canUseCoupon($this->getUserId(),$order_info['goods_price']);
$order_info['canUseCoupon'] = $coupon_record_model->where('id','in',$canUseCoupon)->sum('num');
//模版消息model
$tmpl_model = new TmplConfig();
//获取模版
$data['tmp_list'] = $tmpl_model->where(['uniacid'=>$this->_uniacid])->where('tmpl_name','in',['shop_order','send_over'])->select()->toArray();
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']:2;
$coupon_id = !empty($input['coupon_id'])?$input['coupon_id']:0;
$address_id = isset($input['address_id'])?$input['address_id']:0;
$is_show = isset($input['is_show'])?$input['is_show']:1;
$no_i = isset($input['no_i'])?$input['no_i']:1;
$order_info = $this->model->payOrderInfo($this->getUserId(),0,$coupon_id,$address_id,$is_show,$send_type,$no_i);
$config_model = new Config();
$address_order_model = new OrderAddress();
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
$top_order_code = orderCode();
$kill_model = new SeckillList();
//校验秒杀活动
$res = $kill_model->userCheck($this->getUserId(),$order_info['kill_atv_id'],$is_show);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
Db::startTrans();
//按农场主生成多个订单
foreach ($order_info['order_goods'] as $value){
$order_insert = [
'uniacid' => $this->_uniacid,
'order_code' => orderCode(),
'top_order_code' => $top_order_code,
'user_id' => $this->getUserId(),
'pay_price' => $value['pay_price'],
'get_integral'=> $value['pay_price'],
'true_price' => $value['pay_price'],
'pay_type' => 1,
'goods_price'=> $value['goods_price'],
'farmer_id' => $value['farmer_id'],
'store_id' => $value['farmer_id'],
'init_price' => $value['init_price'],
'init_goods_price' => $value['init_goods_price'],
'text' => $input['text'],
'over_time' => !empty($order_info['kill_atv_id'])?time()+$order_info['kill_over_time']*60:time()+$config['over_time']*60,
'send_type' => $send_type,
'discount' => $value['coupon_discount'],
'freight' => $value['freight'],
'distance' => $value['distance'],
'balance' => $input['pay_model']==2?$value['pay_price']:0,
'total_price' => $order_info['pay_price'],
'send_start_time' => $input['start_time'],
'send_end_time' => $input['end_time'],
'pay_model' => $input['pay_model'],
'kill_atv_id' => $order_info['kill_atv_id'],
'kill_discount_price' => $value['kill_discount_price'],
'integral' => $no_i==0?$value['integral']:0,
'integral_discount_price' => $no_i==0?$value['integral_discount_price']:0,
];
//下单
$res = $this->model->dataAdd($order_insert);
if($res!=1){
Db::rollback();
$this->errorMsg('下单失败');
}
$order_id = $this->model->getLastInsID();
//添加下单地址
$res = $address_order_model->orderAddressAdd($input['address_id'],$order_id,$send_type,5,$input);
if(!empty($res['code'])){
Db::rollback();
$this->errorMsg($res['msg']);
}
$order_insert['id'] = $order_id;
if(empty($order_info['order_goods'])){
$this->errorMsg('订单错误');
}
//添加到子订单
$res = $this->order_goods_model->orderGoodsAdd($value['goods_list'],$order_id,$this->getUserId(),$value['farmer_id'],$input['address_id']);
if(!empty($res['code'])){
Db::rollback();
$this->errorMsg($res['msg']);
}
//使用优惠券
if(!empty($order_info['coupon_id'])){
$this->model->dataUpdate(['id'=>$order_id],['coupon_id'=>$coupon_id]);
}
//积分活动
$res = $this->model->marketingCheck($order_insert,$value['goods_list']);
if(!empty($res['code'])){
Db::rollback();
$this->errorMsg($res['msg']);
}
}
//使用优惠券
if(!empty($order_info['coupon_id'])){
$coupon_record_model = new CouponRecord();
$coupon_record_model->couponUse($order_info['coupon_id']);
}
Db::commit();
//如果是0元
if($order_info['pay_price']<=0){
$this->model->orderResult($top_order_code,$top_order_code);
return $this->success(true);
}
//余额支付
if($input['pay_model']==2){
$user_model = new \app\farm\model\User();
$user_balance= $user_model->where(['id'=>$this->getUserId()])->value('balance');
if($user_balance<$order_info['pay_price']){
$this->errorMsg('余额不足');
}
$this->model->orderResult($top_order_code,$top_order_code);
return $this->success(true);
}elseif ($input['pay_model']==3){
$pay_model = new PayModel($this->payConfig());
$jsApiParameters = $pay_model->aliPay($top_order_code,$order_info['pay_price'],'商场商品');
$arr['pay_list']= $jsApiParameters;
$arr['order_code']= $order_insert['order_code'];
}else{
//微信支付
$pay_controller = new IndexWxPay($this->app);
//支付
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"商城",['type' => 'SchoolShop' , 'out_trade_no' => $top_order_code],$order_info['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($order_insert['pay_model']==2){
$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);
}elseif ($order_insert['pay_model']==3){
$pay_model = new PayModel($this->payConfig());
$jsApiParameters = $pay_model->aliPay($order_insert['order_code'],$order_insert['pay_price'],'商场商品');
$arr['pay_list']= $jsApiParameters;
$arr['order_code']= $order_insert['order_code'];
}else{
//微信支付
$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']);
}
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 ShopOrderGoods();
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 ShopOrder();
$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('订单状态错误');
}
$refund_model = new ShopRefund();
//判断有无申请中的退款订单
$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;
$send_type = isset($input['send_type'])?$input['send_type']:2;
$no_i = isset($input['no_i'])?$input['no_i']:1;
$order_info = $this->model->payOrderInfo($this->getUserId(),0,0,0,$is_show,$send_type,$no_i);
$coupon_id = $coupon_model->canUseCoupon($this->getUserId(),$order_info['goods_price'],1);
$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);
}
/**
* @author chenniang
* @DataTime: 2021-11-16 14:42
* @功能说明:订阅消息通知
*/
public function tmplList(){
$tmpl_model = new TmplConfig();
$dis = [
'uniacid' => $this->_uniacid
];
$data = $tmpl_model->where($dis)->select()->toArray();
return $this->success($data);
}
}

View File

@@ -0,0 +1,259 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\Config;
use app\farm\model\FinanceWater;
use app\farm\model\User;
use app\farm\model\Wallet;
use app\shop\model\DistributionCash;
use app\shop\model\DistributionList;
use think\App;
use think\facade\Db;
use think\Request;
class IndexReseller extends ApiRest
{
protected $model;
protected $user_model;
protected $cash_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new DistributionList();
$this->user_model = new User();
$this->cash_model = new DistributionCash();
$dis = [
'status' => 2,
'user_id'=> $this->getUserId()
];
$reseller = $this->model->dataInfo($dis);
if(empty($reseller)){
$this->errorMsg('你还不是分销商');
}
}
/**
* @author chenniang
* @DataTime: 2022-02-22 13:53
* @功能说明:分销中心
*/
public function resellerInfo(){
$user = $this->user_model->dataInfo(['id'=>$this->getUserId()],'id,nickName,avatarUrl,fx_code,fx_cash');
if(empty($user['fx_code'])){
$user['fx_code'] = getCardCode();
$this->user_model->dataUpdate(['id'=>$user['id']],['fx_code'=>$user['fx_code']]);
}
$dis = [
'user_id' => $this->getUserId(),
'status' => 1
];
$user['notreceived_cash'] = $this->cash_model->where($dis)->sum('cash');
$wallet_model = new Wallet();
$user['wallet_price'] = $wallet_model->where(['user_id'=>$this->getUserId(),'type'=>5])->where('status','in',[1,2])->sum('pay_price');
return $this->success($user);
}
/**
* @author chenniang
* @DataTime: 2022-07-27 18:00
* @功能说明:订单列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['user_id','=',$this->getUserId()];
if(!empty($input['status'])){
$dis[] = ['status','=',$input['status']];
}else{
$dis[] = ['status','>',-1];
}
if(!empty($input['type'])){
$dis[] = ['type','=',$input['type']];
}
$data = $this->cash_model->dataList($dis);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['source_info'] = $this->user_model->where(['id'=>$v['source_id']])->field('nickName,avatarUrl')->find();
$v['order_price'] = array_sum(array_column($v['order_goods'],'pay_price'));
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-28 14:23
* @功能说明:我的团队
*/
public function myTeam(){
$input = $this->_param;
$data = $this->model->myTeam($this->getUserId(),$input['type']);
$data['one_count'] = $this->model->teamCount($this->getUserId());
$data['two_count'] = $this->model->teamCount($this->getUserId(),2);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-12-30 11:15
* @功能说明:申请提现
*/
public function applyWallet(){
$input = $this->_input;
$wallet_model = new Wallet();
$user = $this->user_model->dataInfo(['id'=>$this->getUserId()]);
if($input['apply_price']>$user['fx_cash']){
$this->errorMsg('余额不足');
}
Db::startTrans();
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'order_code' => orderCode(),
'farmer_id' => 0,
'pay_price' => $input['apply_price'],
'text' => $input['text'],
'true_price' => round($input['apply_price'],2),
'balance' => 100,
'type' => 5
];
//发起提现
$res = $wallet_model->dataAdd($insert);
if($res==0){
Db::rollback();
$this->errorMsg('申请失败');
}
$res = $this->user_model->dataUpdate(['id'=>$this->getUserId(),'fx_cash'=>$user['fx_cash']],['fx_cash'=>$user['fx_cash']-$input['apply_price']]);
if($res==0){
Db::rollback();
$this->errorMsg('申请失败');
}
Db::commit();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-07-28 15:02
* @功能说明:提现记录
*/
public function walletList(){
$input = $this->_param;
$dis = [
'user_id' => $this->getUserId(),
'type' => 5
];
if(!empty($input['status'])){
$dis['status'] = $input['status'];
}
$wallet_model = new Wallet();
$data = $wallet_model->dataList($dis);
return $this->success($data);
}
}

View File

@@ -0,0 +1,963 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\Breed;
use app\farm\model\BreedOrder;
use app\farm\model\Claim;
use app\farm\model\ClaimOrder;
use app\farm\model\ClaimText;
use app\farm\model\Config;
use app\farm\model\Evaluate;
use app\farm\model\FinanceWater;
use app\farm\model\Goods;
use app\farm\model\GoodsCate;
use app\farm\model\GoodsSh;
use app\farm\model\LandCate;
use app\farm\model\LandList;
use app\farm\model\LandOrder;
use app\farm\model\LandSourceText;
use app\farm\model\LandSpe;
use app\farm\model\LandText;
use app\farm\model\Machine;
use app\farm\model\Massif;
use app\farm\model\Address;
use app\farm\model\Farmer;
use app\farm\model\Monitor;
use app\farm\model\MonitorText;
use app\farm\model\Seed;
use app\farm\model\SendOrder;
use app\farm\model\ShopGoods;
use app\farm\model\ShopGoodsCate;
use app\farm\model\ShopGoodsSh;
use app\farm\model\ShopOrder;
use app\farm\model\Source;
use app\farm\model\SourceText;
use app\farm\model\User;
use app\farm\model\Wallet;
use app\farm\model\ShopRefund;
use longbingcore\wxcore\WxSetting;
use think\App;
use think\facade\Db;
use think\Request;
class IndexStore extends ApiRest
{
protected $model;
protected $address_model;
protected $massif_model;
protected $land_model;
protected $user_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Farmer();
$this->user_model = new User();
$dis = [
'type' => 2,
'status' => 2,
'user_id'=> $this->getUserId()
];
$this->store = $this->model->dataInfo($dis);
if(empty($this->store)){
$this->errorMsg('你还不是地主');
}
$this->address_model = new Address();
$this->land_model = new LandList();
$this->massif_model = new Massif();
}
/**
* @author chenniang
* @DataTime: 2022-02-22 13:53
* @功能说明:店铺详情
*/
public function storeInfo(){
return $this->success($this->store);
}
/**
* @author chenniang
* @DataTime: 2022-02-22 13:54
* @功能说明:修改店铺
*/
public function storeUpdate(){
$input = $this->_input;
$dis = [
'id' => $this->store['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-23 09:34
* @功能说明:商品分类列表
*/
public function goodsCateList(){
$cate_model = new ShopGoodsCate();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$dis[] = ['store_id','=',$this->store['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['store_id'] = $this->store['id'];
$cate_model = new ShopGoodsCate();
$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 ShopGoodsCate();
$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 ShopGoodsCate();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
$dis[] = ['store_id','=',$this->store['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,
'store_id' => $this->store['id'],
'status' => 1
];
$goods_model = new ShopGoods();
//上架数量
$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[] = ['store_id','=',$this->store['id']];
$dis[] = ['status','=',$input['status']];
//商品名字搜索
if(!empty($input['goods_name'])){
$dis[] = ['goods_name','like','%'.$input['goods_name'].'%'];
}
$goods_model = new ShopGoods();
$data = $goods_model->dataList($dis,10);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
//创建时间
$v['create_time'] = date('Y/m/d',$v['create_time']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 10:44
* @功能说明:商品详情
*/
public function goodsInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$goods_model = new ShopGoods();
$data = $goods_model->dataInfo($dis);
$farmer_model = new Farmer();
$source_model = new Source();
$cate_model = new ShopGoodsCate();
$data['farmer_title'] = $farmer_model->where(['id'=>$data['farmer_id']])->value('title');
$data['source_title'] = $source_model->where(['id'=>$data['source_id']])->value('title');
$data['cate_title'] = $cate_model->where(['id'=>$data['cate_id']])->value('title');
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['store_id']= $this->store['id'];
$input['user_id'] = $this->getUserId();
$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'])){
$input['text'] = serialize($input['text']);
}
// if(!empty($input['text'])){
//
// $rest = $core->wxContentRlue($input['text']);
//
// if($rest['errcode'] != 0){
//
// return $this->error('标题含有违法违规内容');
// }
//
// }
$goods_model = new ShopGoods();
$id = $goods_model->dataAdd($input);
return $this->success(1);
}
/**
* @author chenniang
* @DataTime: 2022-02-25 17:49
* @功能说明:编辑商品
*/
public function goodsUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$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('标题含有违法违规内容');
// }
//
// }
if(!empty($input['text'])){
$input['text'] = serialize($input['text']);
}
if(isset($input['imgs'])){
$input['imgs'] = !empty($input['imgs'])?implode(',',$input['imgs']):'';
}
$goods_model = new ShopGoods();
$input['uniacid'] = $this->_uniacid;
$res = $goods_model->goodsUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 11:44
* @功能说明:商品上下家删除
*/
public function goodsStatusUpdate(){
$input = $this->_input;
$goods_model = new ShopGoods();
$dis = [
'id' => $input['id']
];
$res = $goods_model->dataUpdate($dis,['status'=>$input['status']]);
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 ShopGoodsSh();
$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 11:31
* @功能说明:商品批量上下架
*/
public function someGoodsUpdate(){
$input = $this->_input;
$goods_model = new ShopGoods();
//全选
if(!empty($input['all'])){
$res = $goods_model->where(['store_id'=>$this->store['id'],'status'=>$input['now_status']])->where('status','>',-1)->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: 2022-02-28 14:08
* @功能说明:添加商品时农场主下拉框
*/
public function goodsFarmerSelect(){
$input = $this->_param;
$order_farmer = $this->model->goodsFarmerSelect($this->getUserId());
$map[] = ['id','in',$order_farmer];
$map[] = ['status','in',[2,3]];
$map[] = ['type','=',1];
$list = $this->model->where($map)->field('id,title')->select()->toArray();
return $this->success($list);
}
/**
* @author chenniang
* @DataTime: 2022-02-28 14:22
* @功能说明:添加商品时溯源下拉框
*/
public function goodsSourceSelect(){
$input = $this->_param;
$land_order_model = new LandOrder();
$source_model = new Source();
$id = $land_order_model->goodsSourceSelect($this->getUserId());
$map[] = ['id','in',$id];
$map[] = ['status','=',1];
$list = $source_model->where($map)->field('id,title')->order('id desc')->select()->toArray();
return $this->success($list);
}
/**
* @author chenniang
* @DataTime: 2022-03-01 11:03
* @功能说明:订单列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.store_id','=',$this->store['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 ShopOrder();
$data = $order_model->indexDataList($dis,$where);
$arr = [
'no_pay_count' => 1,
//未发货
'no_send_count' => 2,
//已经发货
'have_send_count'=> 3
];
foreach ($arr as $ks=>$vs){
$map = [
'store_id'=> $this->store['id'],
'pay_type'=> $vs
];
$data[$ks] = $order_model->where($map)->count();
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-07 10:31
* @功能说明:分配订单给农场主
*/
public function distributionOrderFarmer(){
$input = $this->_input;
$order_model = new ShopOrder();
$dis = [
'id' => $input['id']
];
$refund_model = new ShopRefund();
//判断有无申请中的退款订单
$refund_order = $refund_model->dataInfo(['order_id'=>$input['id'],'status'=>1]);
if(!empty($refund_order)){
$this->errorMsg('该订单正在申请退款,请先处理再核销');
}
$res = $order_model->dataUpdate($dis,['farmer_show'=>1]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:58
* @功能说明:订单详情
*/
public function orderInfo(){
$input = $this->_param;
$order_model = new ShopOrder();
$dis = [
'id' => $input['id']
];
$data = $order_model->dataInfo($dis);
$data['over_time'] -= time();
$time_arr = ['create_time','pay_time','end_time','hx_time','over_time','cancel_time'];
foreach ($time_arr as $v){
$data[$v] = !empty($data[$v])?date('Y-m-d H:i:s',$data[$v]):$data[$v];
}
$data['distance'] = distance_text($data['distance']);
//配送时间
$data['user_send_time'] = date('Y-m-d H:i',$data['send_start_time']).'~'.date('H:i',$data['send_end_time']);
$farmer_model = new Farmer();
$data['farmer_info'] = $farmer_model->dataInfo(['id'=>$data['farmer_id']],'title');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 17:29
* @功能说明:退款订单详情
*
*/
public function refundOrderList(){
$input = $this->_param;
$refund_model = new ShopRefund();
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.store_id','=',$this->store['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];
}
$data = $refund_model->indexDataList($dis,$where);
$map = [
'status' => 1,
'store_id'=> $this->store['id']
];
//退款中数量
$data['ing_count'] = $refund_model->where($map)->count();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 09:21
* @功能说明:拒绝退款
*/
public function noPassRefund(){
$input = $this->_input;
$refund_order_model = new ShopRefund();
$res = $refund_order_model->noPassRefund($input['id'],$this->getUserId());
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;
$refund_order_model = new ShopRefund();
$res = $refund_order_model->passOrder($input['id'],$input['price'],$this->payConfig(),$this->getUserId(),$input['text']);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 17:50
* @功能说明:退款订单详情
*/
public function refundOrderInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$refund_order_model = new ShopRefund();
$data = $refund_order_model->dataInfo($dis);
$order_model = new ShopOrder();
$data['pay_order_code'] = $order_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-12-30 11:15
* @功能说明:申请提现
*/
public function applyWallet(){
$input = $this->_input;
$wallet_model = new Wallet();
$config_model = new Config();
$user = $this->user_model->dataInfo(['id'=>$this->getUserId()]);
$config = $config_model->dataInfo(['uniacid'=>$this->_uniacid]);
if($input['apply_price']>$user['wallet_cash']){
$this->errorMsg('余额不足');
}
Db::startTrans();
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'order_code' => orderCode(),
'store_id' => $this->store['id'],
'pay_price' => $input['apply_price'],
'text' => $input['text'],
'true_price' => round($input['apply_price']*$config['cash_balance']/100,2),
'balance' => $config['cash_balance'],
'type' => 2,
];
//发起提现
$res = $wallet_model->dataAdd($insert);
if($res==0){
Db::rollback();
$this->errorMsg('申请失败');
}
$water_model = new FinanceWater();
$id = $wallet_model->getLastInsID();
//添加提现记录
$res = $water_model->addWater($id,15,2,1);
if($res==0){
Db::rollback();
$this->errorMsg('申请失败');
}
$id = $water_model->getLastInsID();
//执行记录
$res = $water_model->cashArrival(0,0,$id);
if($res==0){
Db::rollback();
$this->errorMsg('申请失败');
}
Db::commit();
return $this->success($res);
}
}

View File

@@ -0,0 +1,999 @@
<?php
namespace app\farm\controller;
use app\ApiRest;
use app\farm\model\BalanceWater;
use app\farm\model\Car;
use app\farm\model\Config;
use app\farm\model\CouponRecord;
use app\farm\model\FinanceWater;
use app\farm\model\SystemInfo;
use app\farm\model\Wallet;
use app\massage\model\CarAtvRecord;
use app\farm\model\Address;
use app\farm\model\User;
use app\farm\model\Farmer;
use app\shop\model\DistributionList;
use think\App;
use think\facade\Db;
class IndexUser extends ApiRest
{
protected $model;
protected $address_model;
protected $record_model;
protected $coupon_record_model;
protected $car_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new User();
$this->address_model = new Address();
$this->record_model = new CarAtvRecord();
$this->car_model = new Car();
$this->coupon_record_model = new CouponRecord();
//积分到账
// point_success($this->_uniacid);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:48
* @功能说明:个人中心
*/
public function index(){
if(empty($this->getUserId())){
return $this->success([]);
}
$data = $this->model->dataInfo(['id'=>$this->getUserId()]);
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['type','=',1];
$cap_dis[] = ['status','in',[1,2,3,4]];
$farmer_model = new Farmer();
//查看是否是团长
$cap_info = $farmer_model->dataInfo($cap_dis);
//-1表示未申请团长1申请中2已通过3取消,4拒绝
$data['farmer_status'] = !empty($cap_info)?$cap_info['status']:-1;
$data['sh_text'] = !empty($cap_info)?$cap_info['sh_text']:'';
$where[] = ['user_id','=',$this->getUserId()];
$where[] = ['status','in',[1,2,3,4]];
$distri_model = new DistributionList();
$fx = $distri_model->dataInfo($where);
$data['fx_status'] = !empty($fx)?$fx['status']:-1;
$data['fx_text'] = !empty($fx)?$fx['sh_text']:'';
//优惠券数
// $data['coupon_count'] = $this->coupon_record_model->couponCount($this->getUserId());
$water_model = new FinanceWater();
//冻结金额
$data['frozen_cash'] = $water_model->landordFrozenCash($this->getUserId());
$data['balance_cash']= round($data['balance'] - $data['wallet_cash'],2);
$data['balance'] += $data['frozen_cash'];
$data['balance'] = round($data['balance'],2);
$info_model = new SystemInfo();
//是否含有未读消息
$data['no_read_info'] = $info_model->userHaveNews($this->getUserId(),$this->_uniacid);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:54
* @功能说明:用户地址列表
*/
public function addressList(){
$dis[] = ['user_id','=',$this->getUserId()];
$dis[] = ['status','>',-1];
$data = $this->address_model->dataList($dis,10);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:57
* @功能说明:用户地址详情
*/
public function addressInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->address_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:58
* @功能说明:添加用户地址
*/
public function addressAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$input['user_id'] = $this->getUserId();
$res = $this->address_model->dataAdd($input);
if($input['status']==1){
$id = $this->address_model->getLastInsID();
$this->address_model->updateOne($id);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:58
* @功能说明:添加用户地址
*/
public function addressUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->address_model->dataUpdate($dis,$input);
if(!empty($input['status'])&&$input['status']==1){
$this->address_model->updateOne($input['id']);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-11 22:54
* @功能说明:获取默认地址
*/
public function getDefultAddress(){
$address_model = new Address();
$address = $address_model->dataInfo(['user_id'=>$this->getUserId(),'status'=>1]);
return $this->success($address);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 16:13
* @功能说明:删除地址
*/
public function addressDel(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->address_model->where($dis)->delete();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-22 13:56
* @功能说明:修改用户信息 授权微信信息等
*/
public function userUpdate(){
$input = $this->_input;
$dis = [
'id' => $this->getUserId()
];
if(isset($input['coupon_atv_id'])){
unset($input['coupon_atv_id']);
}
if(isset($input['watermark'])){
unset($input['watermark']);
}
if(isset($input['openId'])){
unset($input['openId']);
}
if(isset($input['unionId'])){
unset($input['unionId']);
}
$res = $this->model->dataUpdate($dis,$input);
$user_info = $this->model->dataInfo(['id'=>$this->getUserId()]);
setCache($this->autograph, $user_info, 7200, $this->_uniacid);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-22 14:08
* @功能说明:用户信息
*/
public function userInfo(){
if(empty($this->getUserId())){
return $this->success([]);
}
$data = $this->model->dataInfo(['id'=>$this->getUserId()]);
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['type','=',1];
$cap_dis[] = ['status','in',[1,2,3,4]];
$farmer_model = new \app\farm\model\Farmer();
//查看是否是团长
$cap_info = $farmer_model->dataInfo($cap_dis);
//-1表示未申请团长1申请中2已通过3取消,4拒绝
$data['farmer_status'] = !empty($cap_info)?$cap_info['status']:-1;
$data['sh_text'] = !empty($cap_info)?$cap_info['sh_text']:'';
$data['balance_cash']= round($data['balance'] - $data['wallet_cash'],2);
$where[] = ['user_id','=',$this->getUserId()];
$where[] = ['status','in',[1,2,3,4]];
$distri_model = new DistributionList();
$fx = $distri_model->dataInfo($where);
$data['fx_status'] = !empty($fx)?$fx['status']:-1;
$data['fx_text'] = !empty($fx)?$fx['sh_text']:'';
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-22 13:35
* @功能说明:申请认证农场主
*/
public function applyFarmer(){
$input = $this->_input;
$farmer_model = new Farmer();
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['status','>',-1];
$cap_dis[] = ['type','=',1];
$cap_info = $farmer_model->dataInfo($cap_dis);
if(!empty($cap_info)&&in_array($cap_info['status'],[1,2,3])){
$this->errorMsg('你已经申请过农场主了,');
}
$input['uniacid'] = $this->_uniacid;
$input['user_id'] = $this->getUserId();
$input['status'] = 1;
$input['imgs'] = !empty($input['imgs'])?implode(',',$input['imgs']):'';
$input['idcard_imgs'] = !empty($input['idcard_imgs'])?implode(',',$input['idcard_imgs']):'';
if(!empty($cap_info)&&$cap_info['status']==4){
$res = $farmer_model->dataUpdate(['id'=>$cap_info['id']],$input);
}else{
$res = $farmer_model->dataAdd($input);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 10:43
* @功能说明:农场主详情
*/
public function farmerInfo(){
if(empty($this->getUserId())){
return $this->success([]);
}
$farmer_model = new Farmer();
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['status','>',-1];
$cap_dis[] = ['type','=',1];
$cap_info = $farmer_model->dataInfo($cap_dis);
return $this->success($cap_info);
}
/**
* @author chenniang
* @DataTime: 2021-07-08 11:51
* @功能说明:用户优惠券列表
*/
public function userCouponList(){
$input = $this->_param;
$this->coupon_record_model->initCoupon($this->_uniacid);
$dis = [
'user_id' => $this->getUserId(),
'status' => $input['status'],
// 'is_show' => 1
];
$data = $this->coupon_record_model->dataList($dis);
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']);
$v['use_time'] = date('Y.m.d H:i',$v['use_time']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 22:09
* @功能说明:删除优惠券
*/
public function couponDel(){
$input = $this->_input;
$coupon = $this->coupon_record_model->dataInfo(['id'=>$input['coupon_id']]);
if($coupon['status']==1){
$this->errorMsg('待使用待卡券不能删除');
}
$res = $this->coupon_record_model->dataUpdate(['id'=>$input['coupon_id']],['is_show'=>0]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 17:40
* @功能说明:生产二维码
*/
public function atvQr(){
$input = $this->_input;
$key = 'atv_coupon'.$input['coupon_atv_id'];
$qr = getCache($key,$this->_uniacid);
if(empty($qr)){
// $qr_insert = [
//
// 'coupon_atv_id' => $input['coupon_atv_id']
// ];
//获取二维码
$qr = $this->model->orderQr($input,$this->_uniacid);
setCache($key,$qr,86400,$this->_uniacid);
}
return $this->success($qr);
}
/**
* @author chenniang
* @DataTime: 2021-07-14 19:22
* @功能说明:授权手机号
*/
public function reportPhone ()
{
$params = $this->_input;
$encryptedData = $params[ 'encryptedData' ];
$iv = $params[ 'iv' ];
$config = longbingGetAppConfig($this->_uniacid);
$appid = $config[ 'appid' ];
// $appsecret = $config[ 'app_secret' ];
$session_key = $this->model->where(['id'=>$this->getUserId()])->value('session_key');
if(empty($session_key)){
$this->errorMsg('need login',401);
}
$data = null;
// 解密
$errCode = decryptDataLongbing( $appid, $session_key, $encryptedData, $iv, $data );
if ( $errCode == 0 )
{
$data = json_decode( $data, true );
$phone = $data[ 'purePhoneNumber' ];
}
else
{
return $this->error( $errCode );
}
$res = $this->model->dataUpdate(['id'=>$this->getUserId()],['phone'=>$phone]);
$user_info = $this->model->dataInfo(['id'=>$this->getUserId()]);
setCache($this->autograph, $user_info, 7200, $this->_uniacid);
return $this->success($phone);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:46
* @功能说明:添加到购物车
*/
public function addCar(){
$input = $this->_input;
$is_show_del = !empty($input['is_show_del'])?$input['is_show_del']:1;
if($is_show_del==1){
$this->car_model->where(['user_id'=>$this->getUserId(),'is_show'=>2])->delete();
}
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'farmer_id' => !empty($input['farmer_id'])?$input['farmer_id']:0,
'goods_id'=> $input['goods_id'],
'spe_id' => !empty($input['spe_id'])?$input['spe_id']:0,
'type' => $input['type'],
'is_show' => !empty($input['is_show'])?$input['is_show']:1,
];
$info = $this->car_model->dataInfo($insert);
//增加数量
if(!empty($info)){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']+$input['goods_num']]);
$id = $info['id'];
}else{
//添加到购物车
$insert['goods_num'] = $input['goods_num'];
$insert['status'] = 1;
$res = $this->car_model->dataAdd($insert);
$id = $this->car_model->getLastInsID();
}
return $this->success($id);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:54
* @功能说明:删除购物车
*/
public function delCar(){
$input = $this->_input;
$info = $this->car_model->dataInfo(['id'=>$input['id']]);
//加少数量
if($info['goods_num']>$input['goods_num']){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']-$input['goods_num']]);
}else{
$res = $this->car_model->where(['id'=>$info['id']])->delete();
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 10:39
* @功能说明:
*/
public function carUpdate(){
$input = $this->_input;
$res = $this->car_model->where('id','in',$input['id'])->update(['status'=>$input['status']]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:59
* @功能说明:批量删除购物车
*/
public function delSomeCar(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'type' => $input['type']
];
$where = [];
if(!empty($input['id'])){
$where[] = ['id','in',$input['id']];
}
$res = $this->car_model->where($dis)->where($where)->delete();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-02-10 11:28
* @功能说明:用户消费流水记录
*/
public function userConsumeWater(){
$input = $this->_param;
$dis[] = ['user_id','=',$this->getUserId()];
if(isset($input['add'])){
$dis[] = ['add','=',$input['add']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$water_model = new BalanceWater();
$data = $water_model->indexList($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-07-21 17:08
* @功能说明:申请分销商
*/
public function applyReseller(){
$input = $this->_input;
$distribution_model = new DistributionList();
$dis[] = ['status','>',-1];
$dis[] = ['user_id','=',$this->getUserId()];
$find = $distribution_model->dataInfo($dis);
if(!empty($find)&&in_array($find['status'],[1,2,3])){
$this->errorMsg('你已经申请');
}
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'user_name'=> $input['user_name'],
'mobile' => $input['mobile'],
'status' => 1,
];
if(!empty($find)&&$find['status']==4){
$res = $distribution_model->dataUpdate(['id'=>$find['id']],$insert);
}else{
$res = $distribution_model->dataAdd($insert);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-08-26 14:07
* @功能说明:绑定分销商
*/
public function bindReseller(){
$input = $this->_input;
$dis = [
'fx_code' => $input['fx_code'],
'uniacid' => $this->_uniacid
];
$data = $this->model->dataInfo($dis);
if(empty($data)){
$this->errorMsg('邀请码无效');
}
if(!empty($this->getUserInfo()['pid'])){
$this->errorMsg('你已经绑定分销商');
}
$update = [
'pid' => $data['id']
];
$res = $this->model->dataUpdate(['id'=>$this->getUserId()],$update);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-23 09:39
* @功能说明:分销商详情
*/
public function resellerInfo(){
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['status','in',[1,2,3,4]];
$distribution_model = new DistributionList();
$cap_info = $distribution_model->dataInfo($cap_dis);
return $this->success($cap_info);
}
/**
* @author chenniang
* @DataTime: 2022-08-23 11:38
* @功能说明:获取app下载地址
*/
public function getAppDownloadQr(){
$data = getCode($this->_uniacid,'www.baidu.com');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2022-03-14 11:55
* @功能说明:发送验证码
*/
public function sendShortMsg(){
$input = $this->_input;
//验证码验证
$config = new Config();
$dis = [
'uniacid' =>$this->_uniacid,
'phone' => $input['phone']
];
$find = $this->model->dataInfo($dis);
if(!empty($find)){
$this->errorMsg('该手机号已经被绑定');
}
$res = $config->sendSms($input['phone'],$this->_uniacid);
if(!empty($res['Message'])&&$res['Message']=='OK'){
return $this->success(1);
}else{
return $this->error($res['Message']);
}
}
/**
* @author chenniang
* @DataTime: 2022-08-26 10:29
* @功能说明:判断用户手机号
*/
public function bindUserPhone(){
$input = $this->_input;
$dis = [
'uniacid' =>$this->_uniacid,
'phone' => $input['phone']
];
$find = $this->model->dataInfo($dis);
if(!empty($find)){
$this->errorMsg('该手机号已经被绑定');
}
$short_code = getCache($input['phone'],$this->_uniacid);
//验证码验证手机号
if($input['short_code']!=$short_code){
return $this->error('验证码错误');
}
$res = $this->model->dataUpdate(['id'=>$this->getUserId()],$dis);
$user = $this->getUserInfo();
$user['phone'] = $input['phone'];
$key = 'longbing_user_autograph_' . $user['id'];
$key = md5($key);
setCache($key, $user, 7200, $this->_uniacid);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2022-08-26 15:45
* @功能说明:通过分销码查找分销商
*/
public function fxcodeUser(){
$input = $this->_param;
$dis = [
'is_fx' => 1,
'fx_code' => $input['fx_code'],
'uniacid' => $this->_uniacid
];
$data = $this->model->dataInfo($dis);
if(!empty($data)){
$fx_model = new DistributionList();
$data['fx_name'] = $fx_model->where(['user_id'=>$data['id'],'status'=>2])->value('user_name');
}
return $this->success($data);
}
}