Queen.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 商店管理
  7. */
  8. namespace app\ais\controller;
  9. use app\ais\model\AisQueen;
  10. use app\ais\controller\Common;
  11. use filter\Filter;
  12. use think\facade\Request;
  13. class Queen extends Common{
  14. public function initialize(){
  15. parent::initialize();
  16. $this->assign('pathMaps',[['name'=>'分帐列表','url'=>url("ais/queen/index")]]);
  17. }
  18. /**
  19. * 微信分账队列
  20. * @return void
  21. */
  22. public function index(int $types = 0,string $order = ''){
  23. $condition = [];
  24. if(!empty($order)){
  25. $condition['out_order_no'] = Filter::filter_escape(trim($order));
  26. }
  27. $store_id = Request::param('store_id',0);
  28. $store_name = Request::param('store_name');
  29. if($store_id){
  30. $condition['store_id'] = $store_id;
  31. }
  32. $view['amount_quree'] = AisQueen::where($this->mini_program)->where($condition)->where(['is_finish' => 0])->sum('amount');
  33. $view['amount_success'] = AisQueen::where($this->mini_program)->where($condition)->where(['is_finish' => 2])->sum('amount');
  34. $view['amount_fail'] = AisQueen::where($this->mini_program)->where($condition)->where(['is_finish' => 1])->sum('amount');
  35. if($types){
  36. switch ($types) {
  37. case 2:
  38. $is_finish = 2;
  39. break;
  40. case 3:
  41. $is_finish = 1;
  42. break;
  43. default:
  44. $is_finish = 0;
  45. break;
  46. }
  47. $condition['is_finish'] = $is_finish;
  48. }
  49. $orderby = $types == 1 ? 'id asc':'id desc';
  50. $view['lists'] = AisQueen::where($this->mini_program)->where($condition)->order($orderby)->paginate(10,false,[
  51. 'query' => ['types' => $types,'store_id' => $store_id,'store_name' => $store_name],
  52. ]);
  53. $view['types'] = $types;
  54. $view['order'] = $order;
  55. $view['store_id'] = $store_id;
  56. $view['store_name'] = $store_name;
  57. $view['pathMaps'] = [['name'=>'结算队列','url'=>url("store/queen")]];
  58. return view()->assign($view);
  59. }
  60. /**
  61. * 重置分账队列
  62. * @return void
  63. */
  64. public function resetQueen(string $order){
  65. $condition = [];
  66. $condition['out_order_no'] = Filter::filter_escape(trim($order));
  67. $condition['is_finish'] = 1;
  68. $rueen = AisQueen::where($this->mini_program)->where($condition)->update(['is_finish' => 0]);
  69. if($rueen){
  70. return json(['code'=>200,'message'=>'成功']);
  71. }else{
  72. return json(['code'=>0,'message'=>'失败,只有分账失败的才允许重置队列']);
  73. }
  74. }
  75. }