|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
+use app\admin\model\WechatPlan;
|
|
|
use app\common\controller\Api;
|
|
|
use app\common\model\{Category, Lave as LaveModel};
|
|
|
use liuniu\repositories\LaveRepository;
|
|
@@ -140,6 +141,99 @@ class Lave extends Api
|
|
|
return $this->error('支付方式错误');
|
|
|
}
|
|
|
|
|
|
+// 支付中签约
|
|
|
+ public function createSign(Request $request)
|
|
|
+ {
|
|
|
+ var_dump(123);die();
|
|
|
+ $where = UtilService::postMore(
|
|
|
+ [
|
|
|
+ ['cid', $this->cid],
|
|
|
+ ['user_id', $this->auth->getUserinfo()['id']],
|
|
|
+ ['order_name', ''],
|
|
|
+ ['category_id', 0],
|
|
|
+ ['amount', 0],
|
|
|
+ ['name', ''],
|
|
|
+ ['contact', ''],
|
|
|
+ ['tel', 0],
|
|
|
+ ['address', ''],
|
|
|
+ ['is_open', '0'],
|
|
|
+ ['is_ticket', '0'],
|
|
|
+ ['pay_type', '0'],
|
|
|
+ ['type', '0'],
|
|
|
+ ['help_id', 0],
|
|
|
+ ['from', 'weixin'],
|
|
|
+ ], $request
|
|
|
+ );
|
|
|
+ $where1 = $where;
|
|
|
+ unset($where1['from']);
|
|
|
+ $where1['order_id'] = LaveModel::getNewOrderId();
|
|
|
+ if (cache('lave_' . $where['user_id'])) $this->error('正在处理中');
|
|
|
+ @file_put_contents("lave.txt", json_encode($where1));
|
|
|
+ $order = LaveModel::create($where1);
|
|
|
+ cache('lave_' . $where['user_id'], '1', 10);
|
|
|
+ if (!$order) $this->error(LaveModel::getErrorInfo());
|
|
|
+ $orderId = $order['order_id'];
|
|
|
+ $info = compact('orderId');
|
|
|
+ $order['plan_id'] = WechatPlan::where('price', $where['amount'])->value('plan_id');
|
|
|
+ if ($orderId) {
|
|
|
+ $orderInfo = LaveModel::where('order_id', $orderId)->find();
|
|
|
+ if (!$orderInfo || !isset($orderInfo['paid'])) $this->error('支付订单不存在!');
|
|
|
+ if ($orderInfo['paid']) $this->error('支付已支付!');
|
|
|
+ try {
|
|
|
+ if ($where['from'] == 'routine') {
|
|
|
+ $jsConfig = LaveRepository::jsPaySign($this->cid, $orderId); //创建订单jspay
|
|
|
+ } else if ($where['from'] == 'weixinh5') {
|
|
|
+ $jsConfig = LaveRepository::h5PaySign($this->cid, $orderId);
|
|
|
+ } else {
|
|
|
+ $jsConfig = LaveRepository::wxPaySign($this->cid, $orderId);
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ $info['jsConfig'] = $jsConfig;
|
|
|
+
|
|
|
+ return $this->success('订单创建成功', $info);
|
|
|
+
|
|
|
+ } else $this->error(LaveModel::getErrorInfo());
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 签约订单支付
|
|
|
+ * @param Request $request
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function paySign(Request $request)
|
|
|
+ {
|
|
|
+ var_dump(456);die();
|
|
|
+ list($uni, $paytype, $from) = UtilService::postMore([
|
|
|
+ ['uni', ''],
|
|
|
+ ['paytype', '0'],
|
|
|
+ ['from', 'weixin']
|
|
|
+ ], $request, true);
|
|
|
+ if (!$uni) $this->error('参数错误!');
|
|
|
+ $order = LaveModel::where('cid', $this->cid)->where('order_id', $uni)->find();
|
|
|
+ if (!$order)
|
|
|
+ $this->error('订单不存在!');
|
|
|
+ if ($order['paid'])
|
|
|
+ $this->error('该订单已支付!');
|
|
|
+ $order['pay_type'] = $paytype; //重新支付选择支付方式
|
|
|
+ switch ($order['pay_type']) {
|
|
|
+ case '0':
|
|
|
+ try {
|
|
|
+ if ($from == 'routine') {
|
|
|
+ $jsConfig = LaveRepository::jsPaySign($this->cid, $order); //订单列表发起支付
|
|
|
+ } else if ($from == 'weixinh5') {
|
|
|
+ $jsConfig = LaveRepository::h5PaySign($this->cid, $order);
|
|
|
+ } else {
|
|
|
+ $jsConfig = LaveRepository::wxPaySign($this->cid, $order);
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success('获取成功', $jsConfig);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return $this->error('支付方式错误');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
?>
|