OrderBehavior.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 = 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. if($data['is_channel']) AdminStoreOrder::refundRoutineTemplate($oid); //TODO 小程序余额退款模板消息
  57. else AdminStoreOrder::refundTemplate($data,$oid);//TODO 公众号余额退款模板消息
  58. }
  59. /**
  60. * 修改状态为 不退款
  61. * @param $data
  62. * $data string 退款原因
  63. * @param $oid
  64. * $oid string store_order表中的id
  65. */
  66. public static function storeProductOrderRefundNAfter($data,$oid){
  67. AdminStoreOrder::refundNoPrieTemplate($oid,$data);
  68. }
  69. /**
  70. * 线下付款
  71. * @param $id
  72. * $id 订单id
  73. */
  74. public static function storeProductOrderOffline($id){
  75. }
  76. /**
  77. * 修改订单状态
  78. * @param $data
  79. * data total_price 商品总价 pay_price 实际支付
  80. * @param $oid
  81. * oid 订单id
  82. */
  83. public static function storeProductOrderEditAfter($data,$oid){
  84. }
  85. /**
  86. * 修改送货信息
  87. * @param $data
  88. * $data array 送货人姓名/快递公司 送货人电话/快递单号
  89. * @param $oid
  90. * $oid string store_order表中的id
  91. */
  92. public static function storeProductOrderDistributionAfter($data,$oid){
  93. }
  94. /**
  95. * 用户申请退款
  96. * @param $oid
  97. * @param $uid
  98. */
  99. public static function storeProductOrderApplyRefundAfter($oid, $uid)
  100. {
  101. $order = AdminStoreOrder::where('id',$oid)->find();
  102. WechatTemplateService::sendAdminNoticeTemplate([
  103. 'first'=>"亲,您有一个订单申请退款 \n订单号:{$order['order_id']}",
  104. 'keyword1'=>'申请退款',
  105. 'keyword2'=>'待处理',
  106. 'keyword3'=>date('Y/m/d H:i',time()),
  107. 'remark'=>'请及时处理'
  108. ]);
  109. }
  110. /**
  111. * 评价产品
  112. * @param $replyInfo
  113. * @param $cartInfo
  114. */
  115. public static function storeProductOrderReply($replyInfo, $cartInfo)
  116. {
  117. //StoreOrder::checkOrderOver($cartInfo['oid']);
  118. }
  119. /**
  120. * 退积分
  121. * @param $product
  122. * $product 商品信息
  123. * @param $back_integral
  124. * $back_integral 退多少积分
  125. */
  126. public static function storeOrderIntegralBack($product,$back_integral){
  127. }
  128. /**
  129. * TODO 后台余额退款
  130. * @param $product
  131. * @param $refund_data
  132. */
  133. public static function storeOrderYueRefund($product,$refund_data)
  134. {
  135. $res = AdminStoreOrder::integralBack($product['id']);
  136. if(!$res) exception('退积分失败!');
  137. }
  138. }