| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace app\controller\api\entropybarter;
- use alipay\aop\AlipayConfig;
- use alipay\aop\AopCertClient;
- use alipay\aop\request\AlipayTradePrecreateRequest;
- use alipay\aop\request\AlipayFundTransUniTransferRequest;
- use crmeb\basic\BaseController;
- use Endroid\QrCode\QrCode;
- use think\db\Where;
- use think\Exception;
- use think\facade\Cache;
- use think\facade\Db;
- class Personal extends BaseController
- {
- /**
- * @return mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * 查询我的粉丝订单
- */
- public function myFansOrderLst()
- {
- $uid=$this->request->uid();
- $mer_id=$this->request->params(['mer_id']);
- $table_name='entropy_barter_user_290';
- [$page,$limit] = $this->getPage();
- if(empty($mer_id['mer_id'])){
- return app('json')->fail('请联系技术人员排查问题,感谢您的反馈');
- }else{
- $mer_id=$mer_id['mer_id'];
- $table_name='entropy_barter_user_'.$mer_id;
- }
- $eb_data=Db::name($table_name)->where('uid',$uid)->find();//5
- $one_data=Db::name($table_name)->where('top_eb_id',$eb_data['eb_id'])->column('uid');//
- $two_data=Db::name($table_name)->whereIn('top_eb_id',Db::name($table_name)->where('top_eb_id',$eb_data['eb_id'])->column('eb_id'))->column('uid');
- $uid_data=array_merge($one_data,$two_data);
- $order_data=Db::name('store_order')
- ->page($page,$limit)->order('order_id','desc')
- ->where('mer_id',$mer_id)
- ->field('order_id,uid,order_sn,create_time,total_price,cart_id')
- ->whereIn('uid',$uid_data)
- ->where('paid'>0)
- ->select();
- if($order_data->isEmpty()){
- return app('json')->fail([]);
- }else{
- $order_data=$order_data->toArray();
- }
- foreach ($order_data as $k=>&$v){
- $bill=Db::name('entropy_barter_bill')->where('mer_id',$mer_id)->field('type,number,status,remarks')->where('order_no',$v['order_sn'])->where('on_line',1)->where('to_id',$eb_data['eb_id'])->select();
- $bill=$bill->toArray();
- foreach ($bill as $ka=>&$va){
- if($va['status']==1){
- $va['status']='待确定';
- }elseif ($va['status']==2){
- $va['status']='有效';
- }elseif ($va['status']==3){
- $va['status']='已失效';
- }
- }
- $v['bill']=$bill;
- $v['product']=Db::name('store_product')->whereIn('product_id',Db::name('store_cart')->where('cart_id','in',$v['cart_id'])->column('product_id'))->field('image,store_name')->select()->toArray();
- }
- $all_commission=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','1')->where('mer_id',$mer_id)->where('type',2)->where('status','<>',3)->sum('number');
- $no_commission=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','1')->where('mer_id',$mer_id)->where('type',2)->where('status',1)->sum('number');
- $wallet=$eb_data['wallet'];
- $withdrawal=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','2')->where('mer_id',$mer_id)->where('pm2_msg','提现')->where('status',2)->sum('number');
- $order_data['top']=[
- 'all_commission'=>bcmul($all_commission,1,2),
- 'no_commission'=>bcmul($no_commission,1,2),
- 'withdrawal'=>bcmul($withdrawal,1,2),
- 'wallet'=>bcmul($wallet,1,2)
- ];
- return app('json')->success($order_data);
- }
- public function myFansOrderLst_new(){
- $uid=$this->request->uid();
- $mer_id=$this->request->params(['mer_id']);
- [$page,$limit] = $this->getPage();
- if(empty($mer_id['mer_id'])){
- return app('json')->fail('请联系技术人员排查问题,感谢您的反馈');
- }else{
- $mer_id=$mer_id['mer_id'];
- $table_name='entropy_barter_user_'.$mer_id;
- }
- $eb_data=Db::name($table_name)->where('uid',$uid)->find();//5
- $bill=Db::name('entropy_barter_bill')
- ->alias('ebb')
- ->join('store_order so','ebb.order_no = so.order_sn')
- ->where('ebb.mer_id',$mer_id)
- ->where('ebb.on_line',1)
- ->where('ebb.to_id',$eb_data['eb_id'])
- ->where('ebb.type',2)
- ->field('ebb.type,ebb.number,ebb.status,ebb.remarks,ebb.order_no,so.cart_id,so.create_time')
- ->page($page,$limit)
- ->order('id','desc')
- ->select();
- if(!$bill){
- return app('json')->success('没有数据');
- }
- $bill=$bill->each(function($item){
- $item['product']=Db::name('store_product')->whereIn('product_id',Db::name('store_cart')->where('cart_id','in',$item['cart_id'])->column('product_id'))->field('image,store_name')->select()->toArray();
- if($item['status']==1){
- $item['status']='待确定';
- }elseif ($item['status']==2){
- $item['status']='有效';
- }elseif ($item['status']==3){
- $item['status']='已失效';
- }
- return $item;
- })->toArray();
- $all_commission=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','1')->where('mer_id',$mer_id)->where('type',2)->where('status','<>',3)->sum('number');//累计佣金
- $no_commission=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','1')->where('mer_id',$mer_id)->where('type',2)->where('status',1)->sum('number');
- $wallet=$eb_data['wallet'];
- $withdrawal=Db::name('entropy_barter_bill')->where('to_id',$eb_data['eb_id'])->where('pm','2')->where('mer_id',$mer_id)->where('pm2_msg','提现')->where('status',2)->sum('number');
- $order_data['list'] = $bill;
- $order_data['top']=[
- 'all_commission'=>bcmul($all_commission,1,2),
- 'no_commission'=>bcmul($no_commission,1,2),
- 'withdrawal'=>bcmul($withdrawal,1,2),
- 'wallet'=>bcmul($wallet,1,2)
- ];
- return app('json')->success($order_data);
- }
- }
|