Reconciliation.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author Qinii
  6. * @day 2020-06-15
  7. *
  8. *
  9. */
  10. namespace app\controller\admin\order;
  11. use think\App;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\system\merchant\MerchantRepository;
  14. use app\common\repositories\store\order\MerchantReconciliationRepository as repository;
  15. class Reconciliation extends BaseController
  16. {
  17. protected $repository;
  18. public function __construct(App $app,repository $repository)
  19. {
  20. parent::__construct($app);
  21. $this->repository = $repository;
  22. }
  23. public function lst()
  24. {
  25. [$page,$limit] = $this->getPage();
  26. $where = $this->request->params(['date','status','keyword','reconciliation_id']);
  27. return app('json')->success($this->repository->getList($where,$page,$limit));
  28. }
  29. public function create($id)
  30. {
  31. if(!app()->make(MerchantRepository::class)->merExists($id))
  32. return app('json')->fail('商户不存在');
  33. $data = $this->request->params([
  34. 'date', //时间
  35. 'order_type', //订单 全选1
  36. 'refund_type', //退款 全选1
  37. ['order_ids',[]], //订单
  38. ['order_out_ids',[]], //排除,不参与对账的订单ID
  39. ['refund_out_ids',[]], //排除,不参与对账的退款订单ID
  40. ['refund_order_ids',[]] //退款段id
  41. ]);
  42. $data['adminId'] = $this->request->adminId();
  43. $this->repository->create($id,$data);
  44. return app('json')->success('对账单生成成功');
  45. }
  46. /**
  47. * TODO 确认打款
  48. * @param $id
  49. * @return mixed
  50. * @author Qinii
  51. * @day 2020-06-15
  52. */
  53. public function switchStatus($id)
  54. {
  55. if(!$this->repository->getWhereCountById($id))
  56. return app('json')->fail('数据不存在或状态错误');
  57. $status = $this->request->param('status') == 1 ? 1 : 0;
  58. $data['is_accounts'] = $status;
  59. if($status == 1) $data['accounts_time'] = date('Y-m-d H:i:s',time());
  60. $this->repository->switchStatus($id,$data);
  61. return app('json')->success('修改成功');
  62. }
  63. public function markForm($id)
  64. {
  65. if(!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  66. return app('json')->fail('数据不存在');
  67. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  68. }
  69. public function mark($id)
  70. {
  71. if(!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  72. return app('json')->fail('数据不存在');
  73. $data = $this->request->params(['admin_mark']);
  74. $this->repository->update($id,$data);
  75. return app('json')->success('备注成功');
  76. }
  77. }