Personal.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace app\controller\api\entropybarter;
  3. use alipay\aop\AlipayConfig;
  4. use alipay\aop\AopCertClient;
  5. use alipay\aop\request\AlipayTradePrecreateRequest;
  6. use alipay\aop\request\AlipayFundTransUniTransferRequest;
  7. use crmeb\basic\BaseController;
  8. use Endroid\QrCode\QrCode;
  9. use think\db\Where;
  10. use think\Exception;
  11. use think\facade\Cache;
  12. use think\facade\Db;
  13. class Personal extends BaseController
  14. {
  15. /**
  16. * @return mixed
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * 查询我的粉丝订单
  21. */
  22. public function myFansOrderLst()
  23. {
  24. $uid=$this->request->uid();
  25. $mer_id=$this->request->params(['mer_id']);
  26. $table_name='entropy_barter_user_290';
  27. [$page,$limit] = $this->getPage();
  28. if(empty($mer_id['mer_id'])){
  29. return app('json')->fail('请联系技术人员排查问题,感谢您的反馈');
  30. }else{
  31. $mer_id=$mer_id['mer_id'];
  32. $table_name='entropy_barter_user_'.$mer_id;
  33. }
  34. $eb_data=Db::name($table_name)->where('uid',$uid)->find();//5
  35. $one_data=Db::name($table_name)->where('top_eb_id',$eb_data['eb_id'])->column('uid');//
  36. $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');
  37. $uid_data=array_merge($one_data,$two_data);
  38. $order_data=Db::name('store_order')
  39. ->page($page,$limit)->order('order_id','desc')
  40. ->where('mer_id',$mer_id)
  41. ->field('order_id,uid,order_sn,create_time,total_price,cart_id')
  42. ->whereIn('uid',$uid_data)
  43. ->where('paid'>0)
  44. ->select();
  45. if($order_data->isEmpty()){
  46. return app('json')->fail([]);
  47. }else{
  48. $order_data=$order_data->toArray();
  49. }
  50. foreach ($order_data as $k=>&$v){
  51. $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();
  52. $bill=$bill->toArray();
  53. foreach ($bill as $ka=>&$va){
  54. if($va['status']==1){
  55. $va['status']='待确定';
  56. }elseif ($va['status']==2){
  57. $va['status']='有效';
  58. }elseif ($va['status']==3){
  59. $va['status']='已失效';
  60. }
  61. }
  62. $v['bill']=$bill;
  63. $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();
  64. }
  65. $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');
  66. $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');
  67. $wallet=$eb_data['wallet'];
  68. $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');
  69. $order_data['top']=[
  70. 'all_commission'=>bcmul($all_commission,1,2),
  71. 'no_commission'=>bcmul($no_commission,1,2),
  72. 'withdrawal'=>bcmul($withdrawal,1,2),
  73. 'wallet'=>bcmul($wallet,1,2)
  74. ];
  75. return app('json')->success($order_data);
  76. }
  77. public function myFansOrderLst_new(){
  78. $uid=$this->request->uid();
  79. $mer_id=$this->request->params(['mer_id']);
  80. [$page,$limit] = $this->getPage();
  81. if(empty($mer_id['mer_id'])){
  82. return app('json')->fail('请联系技术人员排查问题,感谢您的反馈');
  83. }else{
  84. $mer_id=$mer_id['mer_id'];
  85. $table_name='entropy_barter_user_'.$mer_id;
  86. }
  87. $eb_data=Db::name($table_name)->where('uid',$uid)->find();//5
  88. $bill=Db::name('entropy_barter_bill')
  89. ->alias('ebb')
  90. ->join('store_order so','ebb.order_no = so.order_sn')
  91. ->where('ebb.mer_id',$mer_id)
  92. ->where('ebb.on_line',1)
  93. ->where('ebb.to_id',$eb_data['eb_id'])
  94. ->where('ebb.type',2)
  95. ->field('ebb.type,ebb.number,ebb.status,ebb.remarks,ebb.order_no,so.cart_id,so.create_time')
  96. ->page($page,$limit)
  97. ->order('id','desc')
  98. ->select();
  99. if(!$bill){
  100. return app('json')->success('没有数据');
  101. }
  102. $bill=$bill->each(function($item){
  103. $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();
  104. if($item['status']==1){
  105. $item['status']='待确定';
  106. }elseif ($item['status']==2){
  107. $item['status']='有效';
  108. }elseif ($item['status']==3){
  109. $item['status']='已失效';
  110. }
  111. return $item;
  112. })->toArray();
  113. $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');//累计佣金
  114. $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');
  115. $wallet=$eb_data['wallet'];
  116. $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');
  117. $order_data['list'] = $bill;
  118. $order_data['top']=[
  119. 'all_commission'=>bcmul($all_commission,1,2),
  120. 'no_commission'=>bcmul($no_commission,1,2),
  121. 'withdrawal'=>bcmul($withdrawal,1,2),
  122. 'wallet'=>bcmul($wallet,1,2)
  123. ];
  124. return app('json')->success($order_data);
  125. }
  126. }