|
|
|
@ -7,16 +7,23 @@ namespace App\Controller; |
|
|
|
use App\Constants\v3\LogLabel; |
|
|
|
use App\Constants\v3\OrderState; |
|
|
|
use App\Constants\v3\OrderType; |
|
|
|
use App\Constants\v3\SsdbKeys; |
|
|
|
use App\Libs\FeiePrintClient; |
|
|
|
use App\Model\v3\Order; |
|
|
|
use App\Model\v3\OrderGoods; |
|
|
|
use App\Model\v3\OrderMain; |
|
|
|
use App\Service\v3\Interfaces\CouponRebateServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\CouponServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\DeviceServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\FeiePrintServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\FinancialRecordServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\GoodsActivityServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\MiniprogramServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\MqttServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\OrderOnlineServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; |
|
|
|
use App\Service\v3\Interfaces\UserServiceInterface; |
|
|
|
use Hyperf\DbConnection\Db; |
|
|
|
use Hyperf\HttpServer\Contract\RequestInterface; |
|
|
|
use Hyperf\HttpServer\Annotation\AutoController; |
|
|
|
use Hyperf\Utils\Coroutine; |
|
|
|
@ -74,6 +81,12 @@ class TestController extends AbstractController |
|
|
|
*/ |
|
|
|
protected $couponRebateService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Inject |
|
|
|
* @var CouponServiceInterface |
|
|
|
*/ |
|
|
|
protected $couponService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Inject |
|
|
|
* @var OrderOnlineServiceInterface |
|
|
|
@ -86,6 +99,18 @@ class TestController extends AbstractController |
|
|
|
*/ |
|
|
|
protected $separateAccountsService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Inject |
|
|
|
* @var GoodsActivityServiceInterface |
|
|
|
*/ |
|
|
|
protected $goodsActivityService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Inject |
|
|
|
* @var FinancialRecordServiceInterface |
|
|
|
*/ |
|
|
|
protected $financialService; |
|
|
|
|
|
|
|
public function index1(RequestInterface $request) |
|
|
|
{ |
|
|
|
// $container = ApplicationContext::getContainer();
|
|
|
|
@ -128,13 +153,13 @@ class TestController extends AbstractController |
|
|
|
// return $result;
|
|
|
|
// }
|
|
|
|
|
|
|
|
$orderMainId = $this->request->input('order_main_id'); |
|
|
|
$globalOrderId = $this->request->input('order_main_id'); |
|
|
|
// 查询订单
|
|
|
|
$orderMain = OrderMain::query() |
|
|
|
->where([ |
|
|
|
'id' => $orderMainId, |
|
|
|
'global_order_id' => $globalOrderId, |
|
|
|
'type' => OrderType::ONLINE, |
|
|
|
'state' => OrderState::UNPAID |
|
|
|
'state' => OrderState::REFUNDING |
|
|
|
]) |
|
|
|
->first(); |
|
|
|
|
|
|
|
@ -142,48 +167,82 @@ class TestController extends AbstractController |
|
|
|
if (empty($orderMain)) { |
|
|
|
$this->log->event( |
|
|
|
LogLabel::ORDER_OFFLINE_PAY_NOTIFY_LOG, |
|
|
|
['global_order_id_fail' => $orderMainId] |
|
|
|
['global_order_id_fail' => $globalOrderId] |
|
|
|
); |
|
|
|
return true; |
|
|
|
} |
|
|
|
// $orderPaid = $this->orderOfflineService->doPaid($orderMainId);
|
|
|
|
|
|
|
|
// 线下回调
|
|
|
|
// $orderPaid = $this->orderOfflineService->doPaid($globalOrderId);
|
|
|
|
// var_dump('orderOfflineService', $orderPaid);
|
|
|
|
// $separate = $this->separateAccountsService->orderOfflinePaid($orderMainId);
|
|
|
|
// $separate = $this->separateAccountsService->orderOfflinePaid($globalOrderId);
|
|
|
|
// var_dump('separateAccountsService', $separate);
|
|
|
|
//
|
|
|
|
// // 喇叭通知,兼容旧音响,MQTT+IOT
|
|
|
|
// $res = $this->mqttService->speakToStore($orderMainId);
|
|
|
|
// $res = $this->mqttService->speakToStore($globalOrderId);
|
|
|
|
// var_dump('mqttService', $res);
|
|
|
|
// $res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMainId);
|
|
|
|
// $res = $this->deviceService->pubMsgToStoreByOrderMainId($globalOrderId);
|
|
|
|
// var_dump('deviceService', $res);
|
|
|
|
//
|
|
|
|
// // 公众号模板消息
|
|
|
|
// $res = $this->miniprogramService->sendTemMsgForOfflineOrder($orderMainId);
|
|
|
|
// $res = $this->miniprogramService->sendTemMsgForOfflineOrder($globalOrderId);
|
|
|
|
// var_dump('miniprogramService', $res);
|
|
|
|
|
|
|
|
// 线上回调
|
|
|
|
// $res = $this->orderOnlineService->doByPaid($globalOrderId);
|
|
|
|
// var_dump('orderOnlineService', $res);
|
|
|
|
// $res = $this->separateAccountsService->orderOnlinePaid($globalOrderId);
|
|
|
|
// var_dump('separateAccountsService', $res);
|
|
|
|
//
|
|
|
|
// // 优惠券返券
|
|
|
|
// $res = $this->couponRebateService->couponRebateInTask($globalOrderId);
|
|
|
|
// var_dump('couponRebateService', $res);
|
|
|
|
//
|
|
|
|
// // 喇叭通知,兼容旧音响,MQTT+IOT
|
|
|
|
// $res = $this->mqttService->speakToStore($globalOrderId);
|
|
|
|
// var_dump('mqttService', $res);
|
|
|
|
// $res = $this->deviceService->pubMsgToStoreByOrderMainId($globalOrderId);
|
|
|
|
// var_dump('deviceService', $res);
|
|
|
|
//
|
|
|
|
// // 公众号模板消息
|
|
|
|
// $res = $this->miniprogramService->sendTemMsgForOnlineOrder($globalOrderId);
|
|
|
|
// var_dump('miniprogramService', $res);
|
|
|
|
//
|
|
|
|
// // 打印订单,自动打印
|
|
|
|
// $res = $this->feiePrintService->feiePrint($globalOrderId);
|
|
|
|
// var_dump('feiePrintService', $res);
|
|
|
|
|
|
|
|
$res = $this->orderOnlineService->doByPaid($orderMainId); |
|
|
|
var_dump('orderOnlineService', $res); |
|
|
|
$res = $this->separateAccountsService->orderOnlinePaid($orderMainId); |
|
|
|
var_dump('separateAccountsService', $res); |
|
|
|
// 退款回调
|
|
|
|
// 添加退款时间
|
|
|
|
$orderMain->refund_time = time(); |
|
|
|
$orderMain->state = OrderState::REFUNDED; |
|
|
|
$res = $orderMain->save(); |
|
|
|
var_dump('$orderMain', $res); |
|
|
|
|
|
|
|
// 退款返还优惠券
|
|
|
|
$res = $this->couponService->orderRefundCoupons($orderMain->global_order_id); |
|
|
|
var_dump('couponService', $res); |
|
|
|
|
|
|
|
// 处理特价商品缓存
|
|
|
|
$orderChildren = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->get()->toArray(); |
|
|
|
$orderGoods = OrderGoods::query() |
|
|
|
->where(['activity_type' => 2]) |
|
|
|
->whereIn('order_id', array_values(array_column($orderChildren, 'id')))->get(); |
|
|
|
foreach ($orderGoods as $key => &$item) { |
|
|
|
$this->goodsActivityService->clearCacheRecord($item['goods_id'], $item['number'], $orderMain->userId); |
|
|
|
} |
|
|
|
|
|
|
|
// 优惠券返券
|
|
|
|
$res = $this->couponRebateService->couponRebateInTask($orderMainId); |
|
|
|
var_dump('couponRebateService', $res); |
|
|
|
var_dump('$orderChildren', $orderChildren); |
|
|
|
|
|
|
|
// 喇叭通知,兼容旧音响,MQTT+IOT
|
|
|
|
$res = $this->mqttService->speakToStore($orderMainId); |
|
|
|
var_dump('mqttService', $res); |
|
|
|
$res = $this->deviceService->pubMsgToStoreByOrderMainId($orderMainId); |
|
|
|
var_dump('deviceService', $res); |
|
|
|
// 添加用户的流水
|
|
|
|
$res = $this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money); |
|
|
|
var_dump('financialService', $res); |
|
|
|
|
|
|
|
// 公众号模板消息
|
|
|
|
$res = $this->miniprogramService->sendTemMsgForOnlineOrder($orderMainId); |
|
|
|
var_dump('miniprogramService', $res); |
|
|
|
// 记录badge
|
|
|
|
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); |
|
|
|
$res = $ssdb->exec('hincr', SsdbKeys::USER_ORDER_BADGE.$orderMain->user_id, 'refund', 1); |
|
|
|
var_dump('$ssdb', $res); |
|
|
|
|
|
|
|
// 打印订单,自动打印
|
|
|
|
$res = $this->feiePrintService->feiePrint($orderMainId); |
|
|
|
var_dump('feiePrintService', $res); |
|
|
|
} |
|
|
|
|
|
|
|
public function index2(RequestInterface $request) |
|
|
|
|