AuctionOrderController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\api\controller\auction;
  3. use app\models\auction\Auction;
  4. use app\models\auction\AuctionApply;
  5. use app\models\auction\AuctionBooking;
  6. use app\models\auction\AuctionGu;
  7. use app\models\auction\AuctionOrder;
  8. use app\models\auction\AuctionPay;
  9. use app\models\auction\AuctionProduct;
  10. use app\models\auction\AuctionTime;
  11. use app\models\user\User;
  12. use app\models\user\UserBill;
  13. use app\Request;
  14. use Monolog\Handler\Curl\Util;
  15. use think\facade\Cache;
  16. use crmeb\services\{
  17. CacheService,
  18. ExpressService,
  19. SystemConfigService
  20. };
  21. use crmeb\services\UtilService;
  22. use crmeb\repositories\OrderRepository;
  23. use think\facade\Db;
  24. use think\facade\Validate;
  25. class AuctionOrderController
  26. {
  27. /**
  28. * 申诉
  29. * @param Request $request
  30. * @return mixed
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. */
  35. public function plead(Request $request)
  36. {
  37. $data = UtilService::postMore([
  38. 'order_id'
  39. ]);
  40. $order = AuctionOrder::where([['order_id', '=', $data['order_id']], ['collection_id', '=', $request->uid()]])->find();
  41. if ($order['appeal'] == 1) return app('json')->fail('该订单已在申诉中');// 失败
  42. if (!$order) return app('json')->fail('没有订单');// 失败
  43. $product = AuctionProduct::where('id', $order['product_id'])->find();
  44. $product['is_show'] = 0;//下架
  45. $product['frozen'] = 1; // 冻结
  46. $order['appeal'] = 1;// 申诉
  47. $order['is_gs'] = 0;
  48. $order->save();
  49. $product->save();
  50. AuctionTime::where([ ['product_id', '=', $product['id']], ['uid', '=', $request->uid()]])->delete();
  51. return app('json')->success('申诉成功');// 失败
  52. }
  53. /**
  54. * 撤销申诉
  55. * @param Request $request
  56. * @return mixed
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\DbException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. */
  61. public function revoke(Request $request)
  62. {
  63. $data = UtilService::postMore([
  64. 'order_id'
  65. ]);
  66. $order = AuctionOrder::where([['order_id', '=', $data['order_id']], ['collection_id', '=', $request->uid()]])->find();
  67. if ($order['appeal'] == 0) return app('json')->fail('该订单未申诉');// 失败
  68. if (!$order) return app('json')->fail('没有订单');// 失败
  69. $product = AuctionProduct::where('id', $order['product_id'])->find();
  70. $product['frozen'] = 0;
  71. $order['appeal'] = 0;// 撤销申诉
  72. $order->save();
  73. $product->save();
  74. return app('json')->success('撤销申诉成功');// 失败
  75. }
  76. /**
  77. * 修改支付凭证
  78. * @param Request $request
  79. * @return mixed
  80. * @throws \think\db\exception\DataNotFoundException
  81. * @throws \think\db\exception\DbException
  82. * @throws \think\db\exception\ModelNotFoundException
  83. */
  84. public function edit_voucher(Request $request)
  85. {
  86. $data = UtilService::getMore([
  87. ['order_id'],
  88. ['image']
  89. ]);
  90. if (!$data['image'] || !$data['order_id']) return app('json')->fail('请上传打款凭证');
  91. $order = AuctionOrder::where('order_id', $data['order_id'])->find();
  92. if (!$order) return app('json')->fail('订单不存在');
  93. if ($order['status'] == 3) return app('json')->fail('当前订单已完成');
  94. $auction = Auction::where('id', $order['auction_id'])->find();
  95. if (strtotime($auction['radd_time']) > time() or strtotime($auction['rend_time']) < time()) return app('json')->fail('未到支付时间,支付时间为'.$auction['radd_time'].'-'.$auction['rend_time']);
  96. $order['upload_image'] = $data['image'];
  97. $order['status'] = 2;
  98. $order['voucher_time'] = time();
  99. if ($order->save()){
  100. return app('json')->successful('上传成功');
  101. }else{
  102. return app('json')->fail('上传失败');
  103. }
  104. }
  105. }