Cashierorderrefund.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\cashier\storeapi\controller;
  13. use app\storeapi\controller\BaseStoreApi;
  14. use app\model\order\OrderRefund as OrderRefundModel;
  15. use addon\cashier\model\order\CashierOrderRefund as CashierOrderRefundModel;
  16. class Cashierorderrefund extends BaseStoreApi
  17. {
  18. /**
  19. * 商品计算
  20. * @return false|string
  21. */
  22. public function getRefundApplyData()
  23. {
  24. $token = $this->checkToken();
  25. if ($token[ 'code' ] < 0) return $this->response($token);
  26. $order_refund_model = new CashierOrderRefundModel();
  27. $params = array (
  28. 'site_id' => $this->site_id,//站点id
  29. 'store_id' => $this->store_id,
  30. 'order_id' => $this->params[ 'order_id' ] ?? 0,
  31. 'refund_array' => $this->params[ 'refund_array' ] ?? '{}',// ['order_goods_id1','order_goods_id2','order_goods_id2']
  32. );
  33. $res = $order_refund_model->getRefundApplyData($params);
  34. return $this->response($res);
  35. }
  36. public function refund()
  37. {
  38. $token = $this->checkToken();
  39. if ($token[ 'code' ] < 0) return $this->response($token);
  40. $order_refund_model = new CashierOrderRefundModel();
  41. $data = [
  42. 'site_id' => $this->site_id,//站点id
  43. 'store_id' => $this->store_id,
  44. 'order_id' => $this->params[ 'order_id' ] ?? 0,
  45. 'refund_transfer_type' => $this->params[ 'refund_transfer_type' ] ?? '',
  46. 'refund_array' => empty($this->params[ 'refund_array' ]) ? [] : json_decode($this->params[ 'refund_array' ], true),// {'order_goods_id1':{'refund_money':10}},
  47. 'refund_reason' => $this->params[ 'refund_reason' ] ?? '',
  48. 'refund_remark' => $this->params[ 'refund_remark' ] ?? '',
  49. 'operator' => $this->user_info,//操作人员,
  50. ];
  51. $res = $order_refund_model->refund($data);
  52. return $this->response($res);
  53. }
  54. /**
  55. * 为维权列表
  56. * @return false|string
  57. */
  58. public function lists()
  59. {
  60. $page_index = $this->params[ 'page' ] ?? 1;
  61. $search = $this->params[ 'search' ] ?? '';
  62. $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
  63. $order_refund_model = new OrderRefundModel();
  64. $condition = [
  65. [ 'nop.site_id', '=', $this->site_id ],
  66. [ 'no.store_id', '=', $this->store_id ]
  67. ];
  68. //商品名称
  69. if (!empty($search)) {
  70. $condition[] = [ 'nop.sku_name|no.order_no', 'like', '%' . $search . '%' ];
  71. }
  72. $list = $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, 'nop.refund_action_time desc');
  73. return $this->response($list);
  74. }
  75. /**
  76. * 详情
  77. * @return false|string
  78. */
  79. public function detail()
  80. {
  81. $token = $this->checkToken();
  82. if ($token[ 'code' ] < 0) return $this->response($token);
  83. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  84. $order_refund_model = new OrderRefundModel();
  85. $detail = $order_refund_model->getRefundDetail($order_goods_id, $this->site_id, $this->store_id);
  86. return $this->response($detail);
  87. }
  88. }