Cashierorderrefund.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. /**
  89. * 同意维权
  90. * @return array|false|string
  91. */
  92. public function agree()
  93. {
  94. $token = $this->checkToken();
  95. if ($token[ 'code' ] < 0) return $this->response($token);
  96. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  97. $order_refund_model = new OrderRefundModel();
  98. $data = array (
  99. "order_goods_id" => $order_goods_id
  100. );
  101. $res = $order_refund_model->orderRefundConfirm($data, $this->user_info);
  102. return $this->response($res);
  103. }
  104. /**
  105. * 拒绝维权
  106. * @return false|string
  107. */
  108. public function refuse()
  109. {
  110. $token = $this->checkToken();
  111. if ($token[ 'code' ] < 0) return $this->response($token);
  112. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  113. $refund_refuse_reason = $this->params[ 'refund_refuse_reason' ] ?? '';
  114. $order_refund_model = new OrderRefundModel();
  115. $data = array (
  116. "order_goods_id" => $order_goods_id,
  117. "refund_refuse_reason" => $refund_refuse_reason
  118. );
  119. $log_data = [
  120. 'uid' => $this->user_info[ 'uid' ],
  121. 'nick_name' => $this->user_info[ 'username' ],
  122. 'action' => '商家拒绝了维权',
  123. 'action_way' => 2
  124. ];
  125. $res = $order_refund_model->orderRefundRefuse($data, $this->user_info, $refund_refuse_reason, $log_data);
  126. return $this->response($res);
  127. }
  128. /**
  129. * 关闭维权
  130. * @return false|string
  131. */
  132. public function close()
  133. {
  134. $token = $this->checkToken();
  135. if ($token[ 'code' ] < 0) return $this->response($token);
  136. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  137. $order_refund_model = new OrderRefundModel();
  138. $res = $order_refund_model->orderRefundClose($order_goods_id, $this->site_id, $this->user_info);
  139. return $this->response($res);
  140. }
  141. /**
  142. * 获取订单项退款信息
  143. * @return false|string
  144. */
  145. public function refundInfo()
  146. {
  147. $token = $this->checkToken();
  148. if ($token[ 'code' ] < 0) return $this->response($token);
  149. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  150. $order_refund_model = new OrderRefundModel();
  151. $res = $order_refund_model->getOrderGoodsRefundInfo($order_goods_id, $this->site_id);
  152. return $this->response($res);
  153. }
  154. /**
  155. * 维权通过
  156. * @return false|string
  157. */
  158. public function complete()
  159. {
  160. $token = $this->checkToken();
  161. if ($token[ 'code' ] < 0) return $this->response($token);
  162. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  163. $refund_money_type = $this->params[ 'refund_money_type' ] ?? '';
  164. $shop_refund_remark = $this->params[ 'shop_refund_remark' ] ?? '';
  165. $refund_real_money = $this->params[ 'refund_real_money' ] ?? 0;
  166. $is_deposit_back = $this->params[ 'is_deposit_back' ] ?? 1;
  167. $order_refund_model = new OrderRefundModel();
  168. $data = array (
  169. "order_goods_id" => $order_goods_id,
  170. 'refund_money_type' => $refund_money_type,
  171. 'shop_refund_remark' => $shop_refund_remark,
  172. 'refund_real_money' => $refund_real_money,
  173. 'is_deposit_back' => $is_deposit_back
  174. );
  175. $log_data = [
  176. 'uid' => $this->user_info[ 'uid' ],
  177. 'nick_name' => $this->user_info[ 'username' ],
  178. 'action' => '商家对维权进行了转账,维权结束',
  179. 'action_way' => 2
  180. ];
  181. $res = $order_refund_model->orderRefundFinish($data, $this->user_info, $log_data);
  182. return $this->response($res);
  183. }
  184. /**
  185. * 维权收货
  186. * @return false|string
  187. */
  188. public function receive()
  189. {
  190. $token = $this->checkToken();
  191. if ($token[ 'code' ] < 0) return $this->response($token);
  192. $order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
  193. $is_refund_stock = $this->params[ 'is_refund_stock' ] ?? 0; // 是否入库
  194. $order_refund_model = new OrderRefundModel();
  195. $data = array (
  196. "order_goods_id" => $order_goods_id,
  197. "is_refund_stock" => $is_refund_stock
  198. );
  199. $res = $order_refund_model->orderRefundTakeDelivery($data, $this->user_info);
  200. return $this->response($res);
  201. }
  202. }