ProductRepositories.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace crmeb\repositories;
  3. use app\models\store\StoreOrder;
  4. use app\models\user\User;
  5. use app\models\user\UserAddress;
  6. use app\models\user\WechatUser;
  7. use crmeb\services\SystemConfigService;
  8. use crmeb\services\WechatTemplateService;
  9. /**
  10. * Class ProductRepositories
  11. * @package crmeb\repositories
  12. */
  13. class ProductRepositories
  14. {
  15. /**
  16. * 用户确认收货
  17. * @param $order
  18. * @param $uid
  19. * @throws \Exception
  20. */
  21. public static function storeProductOrderUserTakeDelivery($order, $uid)
  22. {
  23. $res1 = StoreOrder::gainUserIntegral($order);
  24. $res2 = User::backOrderBrokerage($order);
  25. StoreOrder::orderTakeAfter($order);
  26. WechatUser::userTakeOrderGiveCoupon($uid, $order['total_price']);//满赠优惠券
  27. if(!($res1 && $res2)) exception('收货失败!');
  28. }
  29. /**
  30. * 订单创建成功后 wap模块
  31. * @param $order
  32. * @param $group
  33. */
  34. public static function storeProductOrderCreateWap($order,$group)
  35. {
  36. UserAddress::be(['is_default'=>1,'uid'=>$order['uid']]) || UserAddress::setDefaultAddress($group['addressId'],$order['uid']);
  37. }
  38. public static function storeProductOrderApplyRefundWap($oid, $uid)
  39. {
  40. $order = StoreOrder::where('id',$oid)->find();
  41. WechatTemplateService::sendAdminNoticeTemplate([
  42. 'first'=>"亲,您有一个订单申请退款 \n订单号:{$order['order_id']}",
  43. 'keyword1'=>'申请退款',
  44. 'keyword2'=>'待处理',
  45. 'keyword3'=>date('Y/m/d H:i',time()),
  46. 'remark'=>'请及时处理'
  47. ]);
  48. }
  49. /**
  50. * 评价商品
  51. * @param $replyInfo
  52. * @param $cartInfo
  53. * @return StoreOrder|\think\Model
  54. */
  55. public static function storeProductOrderReplyWap($replyInfo, $cartInfo)
  56. {
  57. return StoreOrder::checkOrderOver($cartInfo['oid']);
  58. }
  59. }