|
|
@@ -10,6 +10,7 @@ use app\common\enum\WorkEnum;
|
|
|
use app\common\enum\YesNoEnum;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use app\common\logic\PaymentLogic;
|
|
|
+use app\common\logic\PayNotifyLogic;
|
|
|
use app\common\logic\RefundLogic;
|
|
|
use app\common\model\coupon\CouponCategory;
|
|
|
use app\common\model\coupon\UserCoupon;
|
|
|
@@ -152,6 +153,7 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
'lon'=>!empty($params['lon'])?$params['lon']:0,
|
|
|
'lat'=>!empty($params['lat'])?$params['lat']:0,
|
|
|
'property_activity_id'=>!empty($params['property_activity_id'])?$params['property_activity_id']:0,
|
|
|
+ 'user_equity_id'=>$params['user_equity_id']??0,
|
|
|
];
|
|
|
|
|
|
//判断是否是加单
|
|
|
@@ -173,6 +175,13 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
|
|
|
$service_work = ServiceWork::create($work_data);
|
|
|
|
|
|
+
|
|
|
+ //使用权益卡时订单应支付金额=0
|
|
|
+ if(isset($params['user_equity_id']) && $params['user_equity_id']){
|
|
|
+ $order_total = 0;
|
|
|
+ $order_amount = 0;
|
|
|
+ }
|
|
|
+
|
|
|
//生成服务订单
|
|
|
$data = [
|
|
|
'work_id'=> $service_work['id'],
|
|
|
@@ -215,6 +224,15 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
'goods_status' => $goods['goods_status'],
|
|
|
]);
|
|
|
Db::commit();
|
|
|
+ if(empty($order_amount)){
|
|
|
+ $is_zero_pay = self::zeroDirectlyPayment([
|
|
|
+ 'attach' => 'goods',
|
|
|
+ 'out_trade_no' => $order['sn'],
|
|
|
+ ]);
|
|
|
+ if($is_zero_pay === false){
|
|
|
+ Log::info('0元支付失败:'.$order['sn']."---".self::getError());
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (\Exception $e) {
|
|
|
self::setError($e->getMessage());
|
|
|
return false;
|
|
|
@@ -1204,4 +1222,71 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 0元支付直接完成支付
|
|
|
+ * @param array $params attach out_trade_no
|
|
|
+ * @return bool|void
|
|
|
+ */
|
|
|
+ public static function zeroDirectlyPayment(array $params, $extra = [])
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $message['out_trade_no'] = mb_substr($params['out_trade_no'], 0, 18);
|
|
|
+ $order = RechargeOrder::where(['sn' => $params['out_trade_no']])->findOrEmpty();
|
|
|
+ if($order->isEmpty() || $order->pay_status == PayEnum::ISPAID) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ switch ($params['attach']) {
|
|
|
+ case 'recharge':
|
|
|
+ PayNotifyLogic::handle('recharge', $params['out_trade_no'], $extra);
|
|
|
+ break;
|
|
|
+ case 'goods':
|
|
|
+ $res = PayNotifyLogic::handle('goods', $params['out_trade_no'], $extra);
|
|
|
+ if($res === true){
|
|
|
+ // 用户下单后,给订单运营专员(配置固定ID)发送公众号提醒(订单信息)
|
|
|
+ $order = RechargeOrder::where('sn', $message['out_trade_no'])
|
|
|
+ ->where('payment_type','IN',[0,1])
|
|
|
+ ->where('pay_status','=',1)
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(!$order->isEmpty()){
|
|
|
+ $workDetail = ServiceWork::findOrEmpty($order->work_id);
|
|
|
+ if(!$workDetail->isEmpty()){
|
|
|
+ event('Notice', [
|
|
|
+ 'scene_id' => 100,
|
|
|
+ 'params' => [
|
|
|
+ 'user_id' => 0,
|
|
|
+ 'order_id' => $workDetail['id'],
|
|
|
+ 'thing3' => $workDetail['title'],
|
|
|
+ 'time6' => $workDetail['appointment_time'],
|
|
|
+ 'phone_number8' => asteriskString($workDetail['mobile']),
|
|
|
+ 'thing5' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单完成通知【给用户】 - 尾款 -通知
|
|
|
+ $order = RechargeOrder::where('sn', $message['out_trade_no'])
|
|
|
+ ->where('payment_type','=',2)
|
|
|
+ ->where('pay_status','=',1)
|
|
|
+ ->findOrEmpty();
|
|
|
+ if(!$order->isEmpty()){
|
|
|
+ event('Notice', [
|
|
|
+ 'scene_id' => 120,
|
|
|
+ 'params' => [
|
|
|
+ 'user_id' => $order['user_id']
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ self::setError($e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|