| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace addons\YunfastPay\backend\controllers;
- use addons\HiGo\common\listeners\order\store\CashierOrderPaidListener;
- use addons\Store\common\events\order\CashierOrderPaidEvent;
- use addons\Store\common\events\order\CashierOrderSettledEvent;
- use addons\Store\common\models\StoreCashierOrder;
- use addons\YunfastPay\common\services\AgentService;
- use addons\YunfastPay\common\services\NotifyService;
- use addons\YunfastPay\common\services\PayService;
- use addons\YunfastPay\common\services\RefundService;
- use addons\YunfastPay\common\services\SplitBillService;
- use addons\YunfastPay\common\services\StoreService;
- use addons\YunfastPay\common\services\trans\nocash\AgentTrans;
- use addons\YunfastPay\common\services\trans\nocash\ScanPayTrans;
- use addons\YunfastPay\common\services\YunPayService;
- use Yii;
- use yii\helpers\Json;
- /**
- * 测试
- * @package addons\YunfastPay\backend\controllers
- */
- class SokabeController extends BaseController
- {
- /**
- * 支付
- *
- * @return void
- */
- public function actionPay()
- {
- try {
- $service = new StoreService(['mall_id' => $this->mall_id]);
- $service->agentBySplitBillLogId(105);
- } catch (\Exception $e) {
- dd($e);
- }
- }
- /**
- * 代付
- *
- * @return void
- */
- public function actionAgent()
- {
- $service = new YunPayService(['mall_id' => $this->mall_id]);
- $agent = new AgentTrans(
- date('YmdHis') . rand(100, 999),
- 0.01,
- '6227003172460193052',
- '杨金城',
- '测试'
- );
- $service->sendPayRq($agent);
- }
- /**
- * 签约链接
- *
- * @return void
- */
- public function actionSign()
- {
- $service = new YunPayService(['mall_id' => $this->mall_id]);
- $url = $service->getSignUrl();
- dd($url);
- }
- public function actionScan()
- {
- $service = new YunPayService(['mall_id' => $this->mall_id]);
- $service->scanUrl();
- }
- public function actionCashier()
- {
- $id = 51;
- $order = StoreCashierOrder::findOne($id);
- // 触发门店收银台订单结算事件
- $event = new CashierOrderSettledEvent($this->mall_id);
- $order_data['order_no'] = $order['order_no'];
- $order_data['amount_received'] = 0.9;
- $order_data['user_id'] = $order['user_id'];
- $order_data['store_id'] = $order['store_id'];
- $order_data['mall_id'] = $order['mall_id'];
- $order_data['type'] = 2; //类型:1:o2o订单;2:o2o收银台订单
-
- Yii::$app->services->events->dispatch($event, $order_data, $event->listeners);
- }
- public function actionNotify()
- {
- $json = <<<EOR
- {
- "chanelType": "1",
- "channelssn": "4292974146842808321215",
- "chnlCd": "sft",
- "cityCode": "420600",
- "districtCode": "420684",
- "mchtCd": "MCHT100142019",
- "mchtName": "湖北盒兴信息科技有限公司",
- "mchtRate": "0.005",
- "mchtRateBase": "0.0035",
- "orderCd": "20230330221392742152914985",
- "orgCd": "202303021805019",
- "outMchtCd": "20230302hx",
- "outOrderId": "TX20230330143140723112837",
- "procCd": "660000",
- "provinceCode": "420000",
- "transAmt": "0.1",
- "transDatetime": "20230330151439",
- "transStatus": "100",
- "trscode": "TRANS0010",
- "txnNum": "1108"
- }
- EOR;
- $data = Json::decode($json);
- $service = new AgentService(['mall_id' => $this->mall_id]);
- // $service = new NotifyService(['mall_id' => $this->mall_id]);
- $service->notify($data);
- }
-
- public function actionRefund()
- {
- // $json = <<<JSON
- // {"id":"742","step_status":"6","address":{"consignee":null,"mobile":null,"address":null},"express":{"saler_express":null,"saler_express_no":null,"customer_name":null}}
- // JSON;
- // $data = Json::decode($json);
- $json = <<<JSON
- {
- "chanelType": "1",
- "channelssn": "MR20230401848927169949978624",
- "chnlCd": "sft",
- "cityCode": "420600",
- "districtCode": "420684",
- "mchtCd": "MCHT100142019",
- "mchtName": "湖北盒兴信息科技有限公司",
- "mchtRate": "0.005",
- "mchtRateBase": "0.0035",
- "orderCd": "20230401789137101353010735",
- "orgCd": "202303021805019",
- "outMchtCd": "20230302hx",
- "outOrderId": "r202304011412514046443398",
- "payType": "alipay",
- "procCd": "660000",
- "provinceCode": "420000",
- "transAmt": "0.06",
- "transDatetime": "20230401141331",
- "transStatus": "100",
- "trscode": "TRANS0002",
- "txnNum": "5301"
- }
- JSON;
- $data = Json::decode($json);
- $service = new RefundService(['mall_id' => $this->mall_id]);
- $service->notify($data);
- }
- public function actionLog()
- {
- $service = new NotifyService(['mall_id' => $this->mall_id]);
-
- $service->addFileLog('123', '123', [123]);
- }
-
- public function actionHai()
- {
- $event = new CashierOrderPaidEvent($this->mall_id);
- $order['id'] = 302;
- $order['operator_id'] = 0;
- $order['operator_name'] = '';
- Yii::$app->services->events->dispatch($event, $order, $event->listeners);
- }
- public function actionC()
- {
- $id = 51;
- $order = StoreCashierOrder::findOne($id);
- // 触发门店收银台订单结算事件
- $order_data['order_no'] = $order['order_no'];
- $order_data['amount_received'] = 0.9;
- $order_data['user_id'] = $order['user_id'];
- $order_data['store_id'] = $order['store_id'];
- $order_data['mall_id'] = $order['mall_id'];
- $order_data['type'] = 2; //类型:1:o2o订单;2:o2o收银台订单
- (new SplitBillService(['mall_id' => $order['mall_id']]))->divide($order_data);
- }
- }
|