123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace app\sub\controller;
- use app\common\library\MobileConstant;
- use app\common\model\Attachment;
- use app\common\model\Mobile;
- use app\common\model\MobileOrder;
- use app\common\service\MobileOrderExport;
- use app\common\service\Refund;
- use app\common\service\SmsSend;
- use app\common\validate\RefundValidate;
- use think\Cookie;
- use think\Db;
- use think\Hook;
- use think\Validate;
- /**
- * 会员中心
- */
- class Order extends SubCommon
- {
- protected $noNeedLogin=[];
- protected $noNeedRight=['mobile','index','refund_log','remark'];
- public function mobile(){
- $data=input();
- $model=new Mobile();
- if(!empty($data['province_id'])){
- $model->where('province_id',$data['province_id']);
- }
- if(!empty($data['city_id'])){
- $model->where('city_id',$data['city_id']);
- }
- if(!empty($data['network']) && !empty(MobileConstant::getNetwork()[$data['network']]['search'])){
- $model->whereIn('network',MobileConstant::getNetwork()[$data['network']]['search']);
- }
- $list=$model->with(['info'])
- ->where('s_id',$this->auth->id)
- ->order('id','desc')
- ->paginate();
- $this->assign('list',$list);
- $this->assign('status',$model::$status);
- $this->assign('network',MobileConstant::getNetwork());
- return view();
- }
- public function index(){
- $data=input();
- $page=input('page',1);
- $limit=input('limit',15);
- $export=input('export');
- $model=(new MobileOrder())
- ->where('s_id',$this->auth->id);
- if(!empty($data['order_no'])){
- $model->where('order_no',$data['order_no']);
- }
- $model
- ->with(['info'])
- ->order('id','desc');
- $extend=[];
- if($export){
- return MobileOrderExport::export((clone $model)->paginate($limit));
- }else{
- $extend['total']=(clone $model)->sum('amount');
- $extend['alipay']=(clone $model)->where('pay_type',1)->sum('amount');
- $extend['wechat']=(clone $model)->where('pay_type',2)->sum('amount');
- $extend['jd']=(clone $model)->where('pay_type',3)->sum('amount');
- $extend['di']=(clone $model)->sum('amount_di');
- $extend['profit']=(clone $model)->sum('amount_profit');
- $extend['refund']=(clone $model)->sum('amount_refund');
- }
- $list=$model->paginate($limit);
- $this->assign('list',$list);
- $this->assign('extend',$extend);
- $this->assign('pay_type',MobileOrder::$payTypes);
- $this->assign('status',MobileOrder::$status);
- return view();
- }
- #退款
- public function refund(){
- $id=input('id',0);
- $data=input();
- if($this->request->isGet()){
- $model=MobileOrder::where('s_id',$this->auth->id)->find($id);
- $this->assign('row',$model);
- return view();
- }else{
- $this->validate($data,RefundValidate::class);
- Db::startTrans();
- $model=MobileOrder::where('s_id',$this->auth->id)->where('id',$id)->lock(true)->findOrFail();
- $model->makeRefund('user',$this->auth->getUser(),$data);
- Db::commit();
- $this->success();
- }
- }
- #退款记录
- public function refund_log(){
- $id=input('id',0);
- $model=MobileOrder::where('s_id',$this->auth->id)->find($id);
- $list=$model->refundLog()
- ->with(['refunduser'])
- ->paginate();
- $this->assign('list',$list);
- return view();
- }
- #备注
- public function remark(){
- $id=input('id',0);
- $model=MobileOrder::where('s_id',$this->auth->id)->find($id);
- if($this->request->isGet()) {
- return view('', compact('model'));
- }else{
- $remark_sub=input('remark_sub');
- $model['remark_sub']=$remark_sub;
- $model->save();
- $this->success();
- }
- }
- }
|