| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- * 支付.
- *
- * @author nj
- * @date 2021-07-21 15:19
- */
- namespace Modules\InnerApi\Controllers;
- use App\Models\Mongo\PayLogsModel;
- use App\Models\Mysql\ChannelModel;
- use Modules\InnerApi\Requests\PayIncRequest;
- use Modules\InnerApi\Responses\SuccessCommonResponse;
- use Modules\InnerApi\Services\PayService;
- class PayController extends BaseController
- {
- public function inc(PayIncRequest $request, PayService $service)
- {
- $arrJson = $this->getJsonData();
- if (!empty($arrJson)) {
- foreach ($arrJson as $k => &$item) {
- $item['agent_uid'] = '';
- $item['is_deduction'] = 0;
- if (!empty($item['share_code']) && empty($item['invite_uid'])) {
- // 兼容一下,置顶定义混乱了, share_code, invite_uid.
- $item['invite_uid'] = $item['share_code'];
- }
- if (!empty($item['channel_uid'])) {
- $channelInfo = ChannelModel::where(['uid' => $item['channel_uid'], 'mom_app_uid' => $item['mom_app_uid']])->first(['agent_uid']);
- if (empty($channelInfo)) {
- logger('新增充值查不到渠道的报错日志:' . json_encode($item, true));
- continue;
- }
- $item['agent_uid'] = $channelInfo->agent_uid;
- $orderInt = PayLogsModel::query()->where(['order_sn' => $item['order_sn'], 'pay_status' => 1, 'order_status' => 1])->count();
- if (empty($orderInt)) {
- // 扣量计算
- $item = $service->oneRandDeduction($item);
- }
- }
- $arrJson[$k] = $item;
- }
- $service->inc($arrJson);
- }
- return new SuccessCommonResponse();
- }
- }
|