GzcNotify.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @package merchant
  4. * @Author: Qinii
  5. * @Date: 2020/5/27
  6. */
  7. namespace app\controller\api\merchant\order;
  8. use app\common\repositories\merchant\order\OrderGzcRepository;
  9. use app\traits\GzcApiRequest;
  10. use think\App;
  11. use crmeb\basic\BaseController;
  12. use app\common\repositories\merchant\order\OrderMerchantRepository;
  13. use think\facade\Db;
  14. use think\facade\Log;
  15. class GzcNotify extends BaseController
  16. {
  17. use GzcApiRequest;
  18. /**
  19. * @var OrderMerchantRepository
  20. */
  21. protected $repository;
  22. /**
  23. * StoreBrand constructor.
  24. * @param App $app
  25. * @param OrderMerchantRepository $repository
  26. */
  27. public function __construct(App $app, OrderMerchantRepository $repository)
  28. {
  29. parent::__construct($app);
  30. $this->repository = $repository;
  31. }
  32. /**
  33. * 入账回调处理
  34. * @return mixed
  35. * @author php迷途小书童
  36. * @created 2021/3/4 15:02
  37. */
  38. public function notify(){
  39. try {
  40. $post = $this->request->post();
  41. Log::info(json_encode($post));
  42. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  43. $order = $OrderGzcRepository->getWhere(['gzc_deposit_no' => $post['depositDetailNo']]);
  44. if (!$order)
  45. return app('json')->fail('error', '订单不存在');
  46. if ($order->success == 1)
  47. return app('json')->fail('error', '入账已确认');
  48. //修改订单状态
  49. Db::transaction(function () use ($order, $post) {
  50. if ($post['isSuccess'] == '2000') {
  51. $order->success = 1;
  52. }
  53. $order->gzc_confirm_result = json_encode($post);
  54. return $order->save();
  55. });
  56. return app('json')->success(['result' => 'SUCCESS']);
  57. } catch (\Throwable $e) {
  58. Log::info($e->getMessage());
  59. return app('json')->fail('error', $e->getMessage());
  60. }
  61. }
  62. }