| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\controllers\v1;
- use AopClient;
- use app\models\Goods;
- use app\models\Option;
- use app\models\Order;
- use app\models\OrderRefund;
- use app\models\PostageRules;
- use app\models\StoreAliMini;
- use app\models\SuperSales;
- use app\modules\admin\models\MerchantForm;
- use app\modules\client\behaviors\Auth;
- use app\modules\client\models\v1\admin\OrderPriceForm;
- use app\modules\client\models\v1\OrderRefundForm;
- use app\modules\client\controllers\BaseController;
- use app\modules\client\models\v1\ExpressDetailForm;
- use app\modules\client\models\v1\order\OrderPayDataForm;
- use app\modules\client\models\v1\order\OrderSubmitForm;
- use app\modules\client\models\v1\order\OrderSubmitPreviewForm;
- use app\modules\client\models\v1\OrderCommentForm;
- use app\modules\client\models\v1\OrderCommentPreview;
- use app\modules\client\models\v1\OrderConfirmForm;
- use app\modules\client\models\v1\OrderDetailForm;
- use app\modules\client\models\v1\OrderListForm;
- use app\modules\client\models\v1\OrderRefundDetailForm;
- use app\modules\client\models\v1\OrderRefundPreviewForm;
- use app\modules\client\models\v1\OrderRefundSendForm;
- use app\modules\client\models\v1\OrderRevokeForm;
- use app\modules\client\models\v1\SaasOrderForm;
- use app\utils\Alipay\alipaySdk\aop\request\AlipayOpenAppQrcodeCreateRequest;
- use app\utils\Delivery\Delivery;
- use app\utils\Delivery\Alipay\ADelivery;
- use app\utils\QrCode;
- use app\utils\ShareQrcode;
- use yii\base\BaseObject;
- use app\modules\admin\models\maiyatian\MaiyatianForm;
- use app\modules\admin\models\keloop\KeloopForm;
- include_once \Yii::$app->basePath . "/utils/Alipay/alipaySdk/aop/AopClient.php";;
- class OrderController extends BaseController
- {
- public function behaviors()
- {
- return parent::behaviors();
- }
- public function actionCheckBuyer()
- {
- $goods_ids = input_params('goods_ids', []);
- $is_shop = input_params('isShop', false);
- $address_id = input_params('address_id', 0);
- $is_giving_gifts = input_params('is_giving_gifts', 0);
- if($is_giving_gifts){
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'ok',
- ]);
- }
- if(empty($goods_ids)){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误',
- ]);
- }
- $goods_id = array_column($goods_ids, 'goods_id');
- if (empty($goods_id)) {
- $goods_id = $goods_ids;
- }
- if (!$is_shop) {
- $address = \app\models\Address::findOne($address_id);
- }
-
- $res = \app\models\OrderRulesBuyerLocation::checkLocationGoodsList($goods_id, $address, get_user_id());
-
- if (!$res) {
- $is_worker = false;
- //拼装goods_list数据
- $goods_list = [];
- foreach ($goods_ids as $goods_id_item) {
- $goods = Goods::findOne($goods_id_item['goods_id'] ?? $goods_id_item);
- if (intval($goods->product_type) === Goods::GOODS_TYPE_WORKER) {
- $is_worker = true;
- }
- $goods_list[] = [
- 'freight' => $goods->freight,
- 'num' => $goods_id_item['num'] ?? 1,
- 'weight' => $goods->weight * ($goods_id_item['num'] ?? 1),
- 'goods_id' => $goods->id,
- ];
- }
- $res = null;
- if ($address) {
- PostageRules::getExpressPriceMore(get_store_id(), $address->city_id, $goods_list, $address->province_id, $res);
- }
- if ($is_worker) {
- $res = null;
- }
- foreach ($goods_ids as $goods_id_item) {
- //是否可以购买超级卖货活动产品
- if (!SuperSales::canSuperSalesOrder(get_user_id(), $goods_id_item['goods_id'] ?? $goods_id_item, get_store_id(), $error_msg)) {
- $res[$goods_id_item['goods_id'] ?? $goods_id_item] = [
- 'status' => false,
- 'msg' => $error_msg,
- ];
- };
- }
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'ok',
- 'data' => $res,
- ]);
- }
- /**
- * 转换mch_list
- */
- public function actionFilterMchList()
- {
- $form = new OrderSubmitPreviewForm();
- $form->attributes = all_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->filter_mch_list());
- }
- /**
- * 新-订单提交前的预览页面
- * @return \yii\web\Response
- */
- public function actionSubmitPreview()
- {
- $form = new OrderSubmitPreviewForm();
- $form->attributes = post_params();
- $form->send = post_params('send','');
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $result = $form->search();
- if ($result['code']) {
- //需求:失败的话 需要让用户选择返回上一页 还是返回购物车 兼容前端
- $result['code'] = 400;
- }
- return $this->asJson($result);
- }
- /**
- * 新-订单提交
- * @return \yii\web\Response
- */
- public function actionSubmit()
- {
- $form = new OrderSubmitForm();
- $form->attributes = post_params();
- $form->send_price = post_params('send_price');
- $form->take_price = post_params('take_price');
- $form->balance = post_params('balance');
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->user = get_user();
- $result = $form->save();
- if ($result['code']) {
- //需求:失败的话 需要让用户选择返回上一页 还是返回购物车 兼容前端
- $result['code'] = 400;
- }
- return $this->asJson($result);
- }
- /**
- * 订单支付数据
- * @return \yii\web\Response
- */
- public function actionPayData()
- {
- $form = new OrderPayDataForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user = get_user();
- $result = $form->search();
- if ($result['code']) {
- //需求:失败的话 需要让用户选择返回上一页 还是返回购物车 兼容前端
- $result['code'] = 400;
- }
- return $this->asJson($result);
- }
- /**
- * 货到付款订单支付
- * @return void
- * User: hankaige
- * DATE TIME: 2022/12/30 15:24
- */
- public function actionMeetPayData(){
- $form = new OrderPayDataForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user = get_user();
- return $this->asJson($form->meetOrderPay());
- }
- public function actionGiftsReceivedAddr()
- {
- $form = new OrderSubmitForm();
- $form->attributes = all_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->user = get_user();
- $result = $form->giftsReceivedAddr(all_params());
- if ($result['code']) {
- //需求:失败的话 需要让用户选择返回上一页 还是返回购物车 兼容前端
- $result['code'] = 400;
- }
- return $this->asJson($result);
- }
- /**
- * 订单列表
- * @return \yii\web\Response
- */
- public function actionList()
- {
- $form = new OrderListForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->search(all_params()));
- }
- /**
- * 订单取消
- * @return \yii\web\Response
- */
- public function actionRevoke()
- {
- $form = new OrderRevokeForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->save());
- }
- /**
- * 订单详情
- * @return \yii\web\Response
- */
- public function actionDetail()
- {
- $form = new OrderDetailForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- if (!empty(get_params('userId'))) {
- $form->user_id = get_params('userId');
- } else {
- $form->user_id = get_user_id();
- }
- return $this->asJson($form->search());
- }
- /**
- * 修改价格
- * @return mixed
- */
- public function actionModifyPrice()
- {
- $form = new OrderPriceForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- return $this->asJson($form->save());
- }
- /**
- * 获取核销码
- * @return \yii\web\Response
- */
- public function actionGetQrcode()
- {
- $order_no = get_params('order_no');
- $order_type = get_params('order_type', '');
- $page = "user/clerk/clerk";
- if ($order_type) {
- $scene = "order_no:{$order_no},type:{$order_type}";
- } else {
- $scene = "{$order_no}";
- }
- $file_name = [
- 'url_path' => ''
- ];
- if (is_wechat_platform()) {
- $file_name = ShareQrcode::wxQrcode($page,$scene);
- }
- if (is_alipay_platform()) {
- $request = new AlipayOpenAppQrcodeCreateRequest();
- $param = [
- 'url_param' => 'user/clerk/clerk',
- 'query_param' => $scene,
- 'describe' => "小程序开发上线使用"
- ];
- $aliConfigQr = $this->aliConfigQr($request, $param);
- $file_name['url_path'] = "";
- if ($aliConfigQr->code === "10000") {
- $file_name['url_path'] = $aliConfigQr->qr_code_url_circle_blue;
- }
- }
- if (is_h5() || is_app_platform()) {
- $fileName = md5('user/clerk/clerk' . $scene.get_store_id());
- // 保存小程序码到文件
- $dir = \Yii::$app->runtimePath . '/image/wx_qrcode';
- if (! is_dir($dir)) {
- mkdir($dir, 0777, true);
- }
- $file_name['url_path'] = str_replace('http://', 'https://', \Yii::$app->request->hostInfo . '/runtime/image/wx_qrcode/' . $fileName. '.jpg');
- QrCode::image(\Yii::$app->request->hostInfo . '/h5/#/user/clerk/clerk?scene='.$scene, 600, false, 'L', 'JPEG', 0, ['255,255,255', '0,0,0'], 1, false, $dir. '/' .$fileName . '.jpg');
- }
- $res = [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'url' => $file_name['url_path'],
- ]
- ];
- return $this->asJson($res);
- }
- /**
- * 订单确认收货
- */
- public function actionConfirm()
- {
- $form = new OrderConfirmForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->save());
- }
- /**
- * 评论预览页面
- */
- public function actionCommentPreview()
- {
- $form = new OrderCommentPreview();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->search());
- }
- /**
- * 评论提交
- */
- public function actionComment()
- {
- $form = new OrderCommentForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->save());
- }
- /**
- * 售后页面
- */
- public function actionRefundPreview()
- {
- $form = new OrderRefundPreviewForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->search());
- }
- /**
- * 售后订单列表
- */
- public function actionRefundList() {
- $form = new OrderListForm();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->order_id = get_params('order_id');
- $form->status = get_params('status');
- return $this->asJson($form->getNewRefundList());
- }
- /**
- * 售后订单列表
- */
- public function actionIntegralList() {
- $form = new OrderListForm();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->getIntegralList());
- }
- /**
- * 售后提交
- */
- public function actionRefund()
- {
- $form = new OrderRefundForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->save());
- }
- /**
- * 售后订单详情
- */
- public function actionRefundDetail()
- {
- $form = new OrderRefundDetailForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->search());
- }
- /**
- * 售后订单取消
- */
- public function actionRefundCancel()
- {
- $t = \Yii::$app->db->beginTransaction();
- try {
- $order_refund_id = post_params('order_refund_id');
- $orderRefund = OrderRefund::findOne(['id' => $order_refund_id, 'is_delete' => 0, 'store_id' => get_store_id()]);
- if (!$orderRefund) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '订单不存在'
- ]);
- }
- if (in_array($orderRefund->status, [0, 3]) && $orderRefund->is_user_send == 0) {
- $orderRefund->is_user_cancel = 1;
- if (!$orderRefund->save()) {
- throw new \Exception($orderRefund->errors[0]);
- }
- $merchant = new MerchantForm();
- $result = $merchant->orderRefundCancel($orderRefund->order_id);
- if ($result['code']) {
- throw new \Exception($result['msg']);
- }
- $t->commit();
- return $this->asJson([
- 'code' => 0,
- 'msg' => '取消成功'
- ]);
- }
- throw new \Exception('取消失败,当前订单在流程中');
- } catch (\Exception $e) {
- $t->rollBack();
- return $this->asJson([
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]);
- }
- }
- /**
- * 售后订单删除
- */
- public function actionRefundDelete()
- {
- $order_refund_id = post_params('order_refund_id');
- $orderRefund = OrderRefund::findOne(['id' => $order_refund_id, 'is_delete' => 0, 'store_id' => get_store_id()]);
- if (!$orderRefund) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '订单不存在'
- ]);
- }
- OrderRefund::updateAll(['user_delete' => 1], ['id' => $order_refund_id]);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功'
- ]);
- }
- /**
- * 全返订单列表
- * @return \yii\web\Response
- */
- public function actionQuanfan()
- {
- $form = new OrderListForm();
- $form->attributes = get_params();
- $form->store_id = $this->store_id;
- $form->user_id = get_user_id();
- return $this->asJson($form->quanfan());
- }
- /**
- * 售后订单用户发货
- * @return \yii\web\Response
- */
- public function actionRefundSend()
- {
- $form = new OrderRefundSendForm();
- $form->attributes = post_params();
- $form->user_id = get_user_id();
- return $this->asJson($form->save());
- }
- /**
- * 订单物流信息
- */
- public function actionExpressDetail()
- {
- $form = new ExpressDetailForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->search());
- }
- /**
- * saas订单列表
- * @return \yii\web\Response
- */
- public function actionSaas() {
- $form = new SaasOrderForm();
- $form->attributes = get_params();
- $form->user_id = get_user_id();
- $form->status = get_params('status');
- return $this->asJson($form->getList());
- }
- /**
- * 同城配送预下单
- * @return \yii\web\Response
- */
- public function actionPreSubmitOrder() {
- $form = new OrderSubmitForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- $form->user = get_user();
- $form->pre_order_data = post_params('data');
- $result = $form->preOrder();
- if ($result['code']) {
- //需求:失败的话 需要让用户选择返回上一页 还是返回购物车 兼容前端
- $result['code'] = 400;
- }
- return $this->asJson($result);
- }
- /**
- * 预取消订单
- * @return \yii\web\Response
- */
- public function actionPreCancelOrder() {
- $order_id = post_params('order_id');
- $reason_id = post_params('reason_id', 5);
- $reason = post_params('reason', '其他原因');
- $order = Order::findOne($order_id);
- if (!$order) {
- $this->asJson([
- 'code' => 1,
- 'msg' => '订单不存在'
- ]);
- }
- $delivery = \app\models\DeliveryKeloop::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery && KeloopForm::isSaasOpen()){
- return $this->asJson([
- 'code' => 0,
- 'msg' => '预取消订单',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- $delivery = \app\models\DeliveryMaiyatian::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery && MaiyatianForm::isopen(get_store_id())){
- return $this->asJson([
- 'code' => 0,
- 'msg' => '预取消订单',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- $delivery = \app\models\DeliveryInfo::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery['is_local'] == 1){
- if($delivery['local_status'] > 0){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '预取消订单失败,原因:已经开始配送',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '预取消订单',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- if($order->alipay_trade_no){
- $res = ADelivery::cancelOrder(1, get_store_id(), get_mini_id(), get_saas_user()->ali_user_id, $order->order_no, $reason_id, $reason);;
- return $res;
- }
- $result = Delivery::preCancelOrder($order->order_no, $reason_id, $reason);
- return $this->asJson($result);
- }
- /**
- * 取消订单
- * @return \yii\web\Response
- */
- public function actionCancelOrder() {
- $order_id = post_params('order_id');
- $reason_id = post_params('reason_id', 5);
- $reason = post_params('reason', '其他原因');
- $order = Order::findOne($order_id);
- if (!$order) {
- $this->asJson([
- 'code' => 1,
- 'msg' => '订单不存在'
- ]);
- }
- $delivery = \app\models\DeliveryKeloop::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery && KeloopForm::isSaasOpen()){
- $reason = Delivery::$validReason[$reason_id];
- $res = KeloopForm::order_canceled(get_store_id(), $order_id, $reason, 1);
- $res['data']['resultcode'] = $res['code'];
- return $this->asJson($res);
- }
- $delivery = \app\models\DeliveryMaiyatian::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery && MaiyatianForm::isopen(get_store_id())){
- $reason = Delivery::$validReason[$reason_id];
- $res = MaiyatianForm::order_canceled(get_store_id(), $order_id, $reason, 1);
- $res['data']['resultcode'] = $res['code'];
- return $this->asJson($res);
- }
- $delivery = \app\models\DeliveryInfo::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]);
- if($delivery['is_local'] == 1){
- if($delivery['local_status'] > 0){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '取消订单失败,原因:已经开始配送',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '取消订单',
- 'data' => [
- 'resultcode' => 0,
- ],
- ]);
- }
- if($order->alipay_trade_no){
- $res = ADelivery::cancelOrder(0, get_store_id(), get_mini_id(), get_saas_user()->ali_user_id, $order->order_no, $reason_id, $reason);;
- return $this->asJson($res);
- }
- $result = Delivery::cancelOrder($order->order_no, $reason_id, $reason);
- return $this->asJson($result);
- }
- /**
- * @return \yii\web\Response
- */
- public function actionUserDelete() {
- $order_id = post_params('order_id');
- $order = Order::findOne(['id' => $order_id, 'user_delete' => 1]);
- if ($order) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '订单已删除'
- ]);
- }
- Order::updateAll(['user_delete' => 1], ['id' => $order_id]);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '删除成功'
- ]);
- }
- public function actionFriendPay() {
- $order_id = post_params('order_id');
- $order = Order::findOne(['id' => $order_id, 'is_delete' => 0]);
- \Yii::warning(['-------- 代付 -------', [$order_id, get_user_id()]]);
- if (get_user_id() != $order->user_id) {
- $order->pay_user_id = get_user_id();
- $order->save();
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success'
- ]);
- }
- public function aliConfigQr($request, $data = [])
- {
- try {
- $third_appid = Option::get("alipay_appid", 0, 'saas')['value'];
- $third_private_key = Option::get("alipay_app_private_key", 0, 'saas')['value'];
- $third_public_key = Option::get("alipay_public_key", 0, 'saas')['value'];
- $data = json_encode($data);
- $config_ali = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay')['value'];
- $config_ali = json_decode($config_ali, true);
- $aop = new AopClient();
- //如果商城的支付宝小程序信息存在,则使用支付宝小程序的配置信息
- if (!empty($config_ali['app_id']) && !empty($config_ali['app_private_key']) && !empty($config_ali['app_public_key'])) {
- $aop->appId = $config_ali['app_id'];
- $aop->rsaPrivateKey = $config_ali['app_private_key'];
- $aop->alipayrsaPublicKey = $config_ali['app_public_key'];
- } else {
- //使用三方的配置信息
- $aop->appId = $third_appid;
- $aop->rsaPrivateKey = $third_private_key;
- $aop->alipayrsaPublicKey = $third_public_key;
- $ali_mini = StoreAliMini::find()->where(['auth_app_id' => $config_ali['app_id'], 'is_cancel' => 0, 'store_id' => get_store_id()])->asArray()->one();
- if (empty($ali_mini)) {
- throw new \Exception("查找小程序信息失败");
- }
- $token = $ali_mini['auth_token'];
- }
- $aop->encryptType = "AES";
- $aop->apiVersion = '1.0';
- $aop->signType = 'RSA2';
- $aop->postCharset = 'utf-8';
- $aop->format = 'json';
- $request->setBizContent($data);
- if (!empty($token)) {
- $result = $aop->execute ($request, null, $token);
- } else {
- $result = $aop->execute ($request);
- }
- $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
- return $result->$responseNode;
- } catch (\Exception $e) {
- return [
- 'code' => 1,
- 'msg' => $e->getMessage()
- ];
- }
- }
- /**
- * 线下转账信息(店铺)
- *
- * @return void
- */
- public function actionPayOfflineSetting()
- {
- $store_id = get_store_id();
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => ['conf' => \app\modules\admin\models\SaasForm::offlineSetting($store_id)],
- 'store_id' => get_store_id(),
- ]);
- }
- /**
- * 点金计划订单详情
- * @return \yii\web\Response
- */
- public function actionGoldplan()
- {
- $form = new OrderDetailForm();
- $orderNo = input_params('order_no', '');
- return $this->asJson($form->goldplan($orderNo));
- }
- public function actionTestAdapay() {
- include_once \Yii::$app->basePath . "/utils/Adapay/AdapaySdk/init.php";
- \AdaPay\AdaPay::init([
- "api_key_live" => "api_live_2fdb32b6-2807-4d4a-99f7-fc0a9b3c8fa5",
- "api_key_test" => "api_test_46be6a5e-c047-4cd0-9aac-c8c73a332f51",
- // "rsa_public_key" => "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCS0Fpi540Y5pPtItiRrsnguG8N22mwbNcHaA+ZfqDxEM32bNoLp7VhV/4T9jUS8plSYkH3kr7xmWl311f0qxEz5S4LbQACN/vDag48zsY2iTulhnCdpbhFqqCVnuK86g7uFyGhy9PJwGscXpmLxXkA1jwEFXM+8NTjfD8YsEdF0QIDAQAB",
- "rsa_private_key" => "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJLQWmLnjRjmk+0i2JGuyeC4bw3babBs1wdoD5l+oPEQzfZs2guntWFX/hP2NRLymVJiQfeSvvGZaXfXV/SrETPlLgttAAI3+8NqDjzOxjaJO6WGcJ2luEWqoJWe4rzqDu4XIaHL08nAaxxemYvFeQDWPAQVcz7w1ON8PxiwR0XRAgMBAAECgYEAgg4gg80rqQtZr5BW2XdFTtUTS+s6zRcdxWnhp9ANMn/4dHwpDHocq4cPhQ9uJMLUH677UR2mGNAWJhuVxyBjs4J2qVFACpU4Ta9BRQXCppao3maB+04Uobik0xObAz6Fj+EitfO3HFrV6ilPtEMtiObd25uS/aQF7tLKgC+rs4ECQQDeTQyAtmWG+5Iacz1uIxLBWIyz5uIwdRb8pAcA/XIR/alv0IOEhPmYTq/6234av6CP9tWl65vOjozBY5D7RbDNAkEAqRHWNu0Zyw6koY6Pu3mivABanY0lZHigdSmxwAQqB8HnUXpuSscj5N1KxlTVvcPw40pbKOCrUoRXib9Cu3rZFQJAZdBkKY9gcLJH+FVPjWIC9QrZZowYjJkULiHyE0IBPLwxHkUh90/wARIJB5v/5cBeiZFDyPpgIfqn/OrdPDhvAQJAUd8JVN/MNcCJiJJ4l9h3LYMeXl0TVmvzh8kBAnMBx2/mjFY1QpDcmN9wbkp2lsZjyC0hp9HkJLlhiprLve3nYQJBAJZ8XdINDo+P9YJLEwMn1OrDG8h071YijgvAvHpZWxb+7GbUhExkDUVaT99jjLzGZ8mVvvTJ/VoqnFu4+ALyAjE=",
- ], "live", true);
- $app_id = 'app_9aa823b9-d959-4307-a931-23ba8780f9aa';
- $open_id = 'oNiCd4gweWf2Irg2K5WfTFWFGEts';
-
- # 初始化支付类
- $payment = new \AdaPaySdk\Payment();
- # 支付设置
- $payment_params = array(
- "app_id"=> $app_id,
- "order_no"=> date("YmdHis").rand(100000, 999999),
- "pay_channel"=> "wx_lite",
- // "time_expire"=> "20200101000000",
- "pay_amt"=> "0.01",
- "goods_title"=> "subject",
- "goods_desc"=> "body",
- "description"=> "description",
-
- 'expend' => [
- 'open_id' => $open_id,
- ],
- 'notify_url' => '',
- );
- # 发起支付
- $payment->create($payment_params);
- # 对支付结果进行处理
- if ($payment->isError()){
- //失败处理
- var_dump($payment->result);
- } else {
- //成功处理
- var_dump($payment->result);
- }
- }
- public function actionGetLocation() {
- $form = new OrderDetailForm();
- $form->attributes = \Yii::$app->request->get();
- $form->attributes = \Yii::$app->request->post();
- $form->store_id = get_store_id();
- return $this->asJson($form->map());
- }
- //单品选择数量退款功能
- public function actionOrderGoodsCancel() {
- $form = new OrderRevokeForm();
- $form->attributes = post_params();
- $form->user_id = get_user_id();
- $form->store_id = get_store_id();
- return $this->asJson($form->orderGoodsCancel());
- }
- //单个待评论列表
- public function actionOrderCommentWaitOnce() {
- $form = new OrderCommentForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->orderCommentOnce());
- }
- //评论列表
- public function actionOrderCommentWaitList() {
- $form = new OrderCommentForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $form->user_id = get_user_id();
- return $this->asJson($form->orderCommentWaitList());
- }
- //已评价列表
- public function actionOrderCommentList() {
- $form = new OrderCommentForm();
- $form->attributes = get_params();
- $form->user_id = get_user_id();
- return $this->asJson($form->orderCommentList());
- }
- }
|