OrderBehavior.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/18
  6. */
  7. namespace behavior\admin;
  8. use app\admin\model\user\User;
  9. use app\admin\model\order\StoreOrder as AdminStoreOrder;
  10. use app\core\util\WechatTemplateService;
  11. class OrderBehavior
  12. {
  13. /**
  14. * 修改发货状态 为送货
  15. * @param $data
  16. * $data array 送货方式 送货人姓名 送货人电话
  17. * @param $oid
  18. * $oid string store_order表中的id
  19. */
  20. public static function storeProductOrderDeliveryAfter($data,$oid){
  21. AdminStoreOrder::orderPostageAfter($oid,$data);
  22. // AdminStoreOrder::sendOrderGoods($oid,$data);
  23. }
  24. /**
  25. * 修改发货状态 为发货
  26. * @param $data
  27. * $data array 发货方式 送货人姓名 送货人电话
  28. * @param $oid
  29. * $oid string store_order表中的id
  30. */
  31. public static function storeProductOrderDeliveryGoodsAfter($data,$oid){
  32. AdminStoreOrder::orderPostageAfter($oid,$data);
  33. }
  34. /**
  35. * 后台修改状态 为已收货
  36. * @param $data
  37. * $data array status 状态为 已收货
  38. * @param $oid
  39. * $oid string store_order表中的id
  40. */
  41. public static function storeProductOrderTakeDelivery($order)
  42. {
  43. $res1 = AdminStoreOrder::gainUserIntegral($order);
  44. $res2 = \app\ebapi\model\user\User::backOrderBrokerage($order);
  45. AdminStoreOrder::orderTakeAfter($order);
  46. if(!($res1 && $res2)) exception('收货失败!');
  47. }
  48. /**
  49. * 修改状态为 已退款
  50. * @param $data
  51. * $data array type 1 直接退款 2 退款后返回原状态 refund_price 退款金额
  52. * @param $oid
  53. * $oid string store_order表中的id
  54. */
  55. public static function storeProductOrderRefundYAfter($data,$oid){
  56. $order=AdminStoreOrder::where(['id'=>$oid])->find();
  57. if($order['is_channel'])
  58. AdminStoreOrder::refundRoutineTemplate($oid); //TODO 小程序余额退款模板消息
  59. else
  60. AdminStoreOrder::refundTemplate($data,$oid);//TODO 公众号余额退款模板消息
  61. }
  62. /**
  63. * 修改状态为 不退款
  64. * @param $data
  65. * $data string 退款原因
  66. * @param $oid
  67. * $oid string store_order表中的id
  68. */
  69. public static function storeProductOrderRefundNAfter($data,$oid){
  70. AdminStoreOrder::refundNoPrieTemplate($oid,$data);
  71. }
  72. /**
  73. * 线下付款
  74. * @param $id
  75. * $id 订单id
  76. */
  77. public static function storeProductOrderOffline($id){
  78. }
  79. /**
  80. * 修改订单状态
  81. * @param $data
  82. * data total_price 商品总价 pay_price 实际支付
  83. * @param $oid
  84. * oid 订单id
  85. */
  86. public static function storeProductOrderEditAfter($data,$oid){
  87. }
  88. /**
  89. * 修改送货信息
  90. * @param $data
  91. * $data array 送货人姓名/快递公司 送货人电话/快递单号
  92. * @param $oid
  93. * $oid string store_order表中的id
  94. */
  95. public static function storeProductOrderDistributionAfter($data,$oid){
  96. }
  97. /**
  98. * 用户申请退款
  99. * @param $oid
  100. * @param $uid
  101. */
  102. public static function storeProductOrderApplyRefundAfter($oid, $uid)
  103. {
  104. $order = AdminStoreOrder::where('id',$oid)->find();
  105. WechatTemplateService::sendAdminNoticeTemplate([
  106. 'first'=>"亲,您有一个订单申请退款 \n订单号:{$order['order_id']}",
  107. 'keyword1'=>'申请退款',
  108. 'keyword2'=>'待处理',
  109. 'keyword3'=>date('Y/m/d H:i',time()),
  110. 'remark'=>'请及时处理'
  111. ]);
  112. }
  113. /**
  114. * 评价产品
  115. * @param $replyInfo
  116. * @param $cartInfo
  117. */
  118. public static function storeProductOrderReply($replyInfo, $cartInfo)
  119. {
  120. //StoreOrder::checkOrderOver($cartInfo['oid']);
  121. }
  122. /**
  123. * 退积分
  124. * @param $product
  125. * $product 商品信息
  126. * @param $back_integral
  127. * $back_integral 退多少积分
  128. */
  129. public static function storeOrderIntegralBack($product,$back_integral){
  130. }
  131. /**
  132. * TODO 后台余额退款
  133. * @param $product
  134. * @param $refund_data
  135. */
  136. public static function storeOrderYueRefund($product,$refund_data)
  137. {
  138. $res = AdminStoreOrder::integralBack($product['id']);
  139. if(!$res) exception('退积分失败!');
  140. }
  141. }