Reconciliation.php 3.3 KB

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