123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace behavior\wechat;
- use app\wap\model\store\StoreOrder as StoreOrderRoutineModel;
- use app\wap\model\store\StoreOrder as StoreOrderWapModel;
- use app\wap\model\user\UserRecharge;
- use service\HookService;
- use service\WechatService;
- use app\wap\model\activity\EventSignUp;
- use app\wap\model\topic\TestPaperOrder;
- use app\wap\model\material\DataDownloadOrder;
- class PaymentBehavior
- {
- /**
- * 下单成功之后
- * @param $order
- * @param $prepay_id
- */
- public static function wechatPaymentPrepare($order, $prepay_id)
- {
- }
- /**
- * 支付成功后
- * @param $notify
- * @return bool|mixed
- */
- public static function wechatPaySuccess($notify)
- {
- if (isset($notify->attach) && $notify->attach) {
- return HookService::listen('wechat_pay_success_' . strtolower($notify->attach), $notify->out_trade_no, $notify, true, self::class);
- }
- return false;
- }
- /**
- * 商品订单支付成功后 微信公众号
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessGoods($orderId, $notify)
- {
- try {
- if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1, 'type' => 2])) return true;
- return StoreOrderWapModel::payGoodsSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 专题订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessSpecial($orderId, $notify)
- {
- try {
- if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return StoreOrderWapModel::paySuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 学习计划订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessPlan($orderId, $notify)
- {
- try {
- if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return StoreOrderWapModel::payPlanSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 会员订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessMember($orderId, $notify)
- {
- try {
- if (StoreOrderWapModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return StoreOrderWapModel::payMeSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 活动报名订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessSignup($orderId, $notify)
- {
- try {
- if (EventSignUp::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return EventSignUp::paySuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 试卷订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessTestpaper($orderId, $notify)
- {
- try {
- if (TestPaperOrder::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return TestPaperOrder::payTestPaperSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 资料订单支付成功后 微信公众号 支付宝
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessDatadownload($orderId, $notify)
- {
- try {
- if (DataDownloadOrder::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return DataDownloadOrder::payDataDownloadSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 商品订单支付成功后 小程序
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessProductr($orderId, $notify)
- {
- try {
- if (StoreOrderRoutineModel::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return StoreOrderRoutineModel::paySuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 用户充值成功后
- * @param $orderId
- * @param $notify
- * @return bool
- */
- public static function wechatPaySuccessRecharge($orderId, $notify)
- {
- try {
- if (UserRecharge::be(['order_id' => $orderId, 'paid' => 1])) return true;
- return UserRecharge::rechargeSuccess($orderId);
- } catch (\Exception $e) {
- return false;
- }
- }
- /**
- * 使用余额支付订单时
- * @param $userInfo
- * @param $orderInfo
- */
- public static function yuePayProduct($userInfo, $orderInfo)
- {
- }
- /**
- * 微信支付订单退款
- * @param $orderNo
- * @param array $opt
- */
- public static function wechatPayOrderRefund($orderNo, array $opt)
- {
- WechatService::payOrderRefund($orderNo, $opt);
- }
- /**
- * 微信支付充值退款
- * @param $orderNo
- * @param array $opt
- */
- public static function userRechargeRefund($orderNo, array $opt)
- {
- WechatService::payOrderRefund($orderNo, $opt);
- }
- }
|