You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
66
hyhproject/app/controller/Uservouchers.php
Executable file
66
hyhproject/app/controller/Uservouchers.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace wstmart\app\controller;
|
||||
use wstmart\app\model\Index as M;
|
||||
use wstmart\admin\model\CashDraws as CM;
|
||||
/**
|
||||
* ============================================================================
|
||||
* 默认控制器
|
||||
*/
|
||||
class Uservouchers extends Base{
|
||||
// 前置方法执行列表
|
||||
protected $beforeActionList = [
|
||||
'checkAuth' => ['except'=>'startgivevouchers,savedaymoney']// 访问这些except下的方法不需要执行前置操作
|
||||
];
|
||||
/**
|
||||
* 保存每日券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function saveDayMoney(){
|
||||
$date = date('Y-m-d');
|
||||
$m = new CM();
|
||||
$m->viewReport($date,1);
|
||||
}
|
||||
/**
|
||||
* 分配券值
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function startGiveVouchers(){
|
||||
Model('UserVouchers')->startGiveVouchers();
|
||||
}
|
||||
//获取券值
|
||||
public function getVouchers(){
|
||||
$m = Model('common/Table');
|
||||
$vouchersType = (int)input('post.vouchersType');//1产品券2优惠券3旺旺券
|
||||
$isExpected = (int)input('post.isExpected');//是否是预获值
|
||||
$userId = $this->getUserId();
|
||||
$list = [];
|
||||
if(1 == $isExpected){
|
||||
if(1 == $vouchersType || 2 == $vouchersType){
|
||||
$vouchersNames = [1=>'expectedProductNum',2=>'expectedCouponsNum'];
|
||||
$m->setTable('user_vouchers_notice');
|
||||
$list = $m->getSelect(['userId'=>$userId,$vouchersNames[$vouchersType]=>['>=',0.01],'isShow'=>1],$vouchersNames[$vouchersType].' num,remark,moneyType,createTime','id DESC');
|
||||
if(!empty($list['Rows'])){
|
||||
foreach ($list['Rows'] as &$v) {
|
||||
$v['createTime'] = date('Y-m-d H:i:s',$v['createTime']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$m->setTable('shops');
|
||||
$shopIds = $m->getColumn(['status'=>1,'userId'=>$userId],'shopId');
|
||||
// dump($shopIds);
|
||||
if($shopIds){
|
||||
$m->setTable('orders');
|
||||
$list = db('orders')->where(['shopId'=>['in',$shopIds],'orderStatus'=>['BETWEEN','0,1'],'num'=>['>=',0.01],'dataFlag'=>1])->field('SUM((productNum - productHandlingFee - productTaxFee) + (couponsNum - couponsHandlingFee - couponsTaxFee) + wangNum) num ,CONCAT("订单编号:",orderNo,",收入") as remark,dataFlag moneyType,createTime')->group('orderId')->order('orderId DESC')->paginate(input('pageSize/d',10))->toArray();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$m->setTable('shops');
|
||||
$shopIds = $m->getColumn(['status'=>1,'userId'=>$userId],'shopId');
|
||||
$m->setTable('log_moneys');
|
||||
$list = db('log_moneys')->where("((targetType = 0 AND targetId = $userId ) OR (targetType = 1 AND targetId IN (".implode(',',$shopIds) ."))) AND moneyName = $vouchersType AND dataFlag=1")->field('money num,remark,moneyType,createTime')->order('id DESC')->paginate(input('pageSize/d',10))->toArray();
|
||||
//dump(db()->_sql());
|
||||
// $list = $m->getSelect(['targetType'=>0,'targetId'=>$userId,'moneyName'=>$vouchersType,'dataFlag'=>1],'money num,remark,moneyType,createTime','id DESC');
|
||||
}
|
||||
exit(jsonReturn('',1,$list));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user