h5逻辑修改

lszyh
lqmac 2 months ago
parent 2ae77cf88f
commit d1add7930e
  1. 4
      app/api/controller/Cashier.php
  2. 1
      app/api/controller/Goods.php
  3. 8
      app/api/controller/Recharge.php
  4. 6
      app/api/model/recharge/Order.php
  5. 14
      app/api/service/Identity.php
  6. 7
      app/api/service/Retail.php
  7. 7
      app/api/service/Setting.php
  8. 7
      app/api/service/cashier/Payment.php
  9. 8
      app/api/service/recharge/Payment.php
  10. 2
      app/command/SyncGoodsToPerMinute.php
  11. 23
      app/common/model/Payment.php
  12. 4
      app/common/model/h5/Setting.php
  13. 39
      app/store/controller/user/Recharge.php
  14. 74
      app/store/model/recharge/Order.php

@ -34,6 +34,10 @@ class Cashier extends Controller
*/ */
public function orderInfo(int $orderId, string $client): Json public function orderInfo(int $orderId, string $client): Json
{ {
//微信端特殊处理一下
if ($client == 'WXOFFICIAL') {
$client = 'H5';
}
$CashierService = new CashierService; $CashierService = new CashierService;
$data = $CashierService->setOrderId($orderId)->setClient($client)->orderInfo(); $data = $CashierService->setOrderId($orderId)->setClient($client)->orderInfo();
return $this->renderSuccess($data); return $this->renderSuccess($data);

@ -85,6 +85,7 @@ class Goods extends Controller
//获取客服设置 //获取客服设置
$service = new SettingService; $service = new SettingService;
$setting = $service->getGoodsCustomer($merchantId,$storeId); $setting = $service->getGoodsCustomer($merchantId,$storeId);
$goodsInfo['setting'] = $setting; $goodsInfo['setting'] = $setting;
return $this->renderSuccess(['detail' => $goodsInfo]); return $this->renderSuccess(['detail' => $goodsInfo]);
} }

@ -33,6 +33,10 @@ class Recharge extends Controller
*/ */
public function center(string $client): Json public function center(string $client): Json
{ {
//微信端特殊处理一下
if ($client == 'WXOFFICIAL') {
$client = 'H5';
}
$RechargeService = new RechargeService; $RechargeService = new RechargeService;
$data = $RechargeService->center($client); $data = $RechargeService->center($client);
return $this->renderSuccess($data); return $this->renderSuccess($data);
@ -49,6 +53,10 @@ class Recharge extends Controller
public function submit(): Json public function submit(): Json
{ {
$data = $this->postForm(); $data = $this->postForm();
if ($data['method'] == 'WXOFFICIAL') {
$data['method'] = 'H5';
}
$RechargeService = new RechargeService; $RechargeService = new RechargeService;
$data = $RechargeService->setMethod($data['method']) $data = $RechargeService->setMethod($data['method'])
->setClient($data['client']) ->setClient($data['client'])

@ -78,7 +78,7 @@ class Order extends OrderModel
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function createOrder(?int $planId = null, ?string $customMoney = null) public function createOrder(?int $planId = null, ?string $customMoney = null, array $extra = [])
{ {
// 确定充值方式 // 确定充值方式
$rechargeType = $planId > 0 ? RechargeTypeEnum::PLAN : RechargeTypeEnum::CUSTOM; $rechargeType = $planId > 0 ? RechargeTypeEnum::PLAN : RechargeTypeEnum::CUSTOM;
@ -89,6 +89,10 @@ class Order extends OrderModel
} }
// 获取订单数据 // 获取订单数据
$data = $this->getOrderData($rechargeType, $planId, $customMoney); $data = $this->getOrderData($rechargeType, $planId, $customMoney);
$data['order']['voucher_type'] = $extra['voucherType'] ?? "";
$data['order']['payer_name'] = $extra['payerName'] ?? "";
$data['order']['payer_phone'] = $extra['payerPhone'] ?? "";
$data['order']['upload_images'] = isset($extra['uploadImages']) && $extra['uploadImages'] ? json_encode($extra['uploadImages']) : "";
// 记录订单信息 // 记录订单信息
return $this->saveOrder($data); return $this->saveOrder($data);
} }

@ -72,6 +72,13 @@ class Identity extends BaseService
// 根据指定客户端获取可用的支付方式 // 根据指定客户端获取可用的支付方式
$PaymentModel = new PaymentModel; $PaymentModel = new PaymentModel;
$methods = $PaymentModel->getMethodsByClient($client); $methods = $PaymentModel->getMethodsByClient($client);
foreach ($methods as $key => $value) {
if ($value['method'] == "voucher") {
unset($methods[$key]);
}
}
$methods = array_values($methods);
// 返回数据 // 返回数据
return [ return [
'personal' => $userInfo, 'personal' => $userInfo,
@ -120,6 +127,13 @@ class Identity extends BaseService
// 根据指定客户端获取可用的支付方式 // 根据指定客户端获取可用的支付方式
$PaymentModel = new PaymentModel; $PaymentModel = new PaymentModel;
$methods = $PaymentModel->getMethodsByClient($client); $methods = $PaymentModel->getMethodsByClient($client);
foreach ($methods as $key => $value) {
if ($value['method'] == "voucher") {
unset($methods[$key]);
}
}
$methods = array_values($methods);
// 返回数据 // 返回数据
return [ return [
'personal' => $userInfo, 'personal' => $userInfo,

@ -72,6 +72,13 @@ class Retail extends BaseService
// 根据指定客户端获取可用的支付方式 // 根据指定客户端获取可用的支付方式
$PaymentModel = new PaymentModel; $PaymentModel = new PaymentModel;
$methods = $PaymentModel->getMethodsByClient($client['client']); $methods = $PaymentModel->getMethodsByClient($client['client']);
foreach ($methods as $key => $value) {
if ($value['method'] == "voucher") {
unset($methods[$key]);
}
}
$methods = array_values($methods);
// 返回数据 // 返回数据
return [ return [
'personal' => $userInfo, 'personal' => $userInfo,

@ -183,6 +183,11 @@ class Setting extends BaseService
public function getGoodsCustomer(int $merchantId ,int $storeId): array public function getGoodsCustomer(int $merchantId ,int $storeId): array
{ {
$values = SettingModel::getItem(SettingEnum::CUSTOMER , $storeId ,$merchantId); $values = SettingModel::getItem(SettingEnum::CUSTOMER , $storeId ,$merchantId);
return helper::pick($values, ['enabled', 'provider', 'config']); $setting = helper::pick($values, ['enabled', 'provider', 'config']);
if (isset($setting['config']['ewmkf']['qrCodeId']) && $setting['config']['ewmkf']['qrCodeId']) {
$info = UploadFile::detail($setting['config']['ewmkf']['qrCodeId']);
$setting['config']['ewmkf']['qrCode'] = $info['preview_url'] ?? "";
}
return $setting;
} }
} }

@ -104,6 +104,13 @@ class Payment extends BaseService
$merchantId = ($model && $model->channel_id > 0) ? 0 : $orderInfo['merchant_id']; $merchantId = ($model && $model->channel_id > 0) ? 0 : $orderInfo['merchant_id'];
$methods = $PaymentModel->getMethodsByClient($this->client, true, $orderInfo['store_id'], $merchantId); $methods = $PaymentModel->getMethodsByClient($this->client, true, $orderInfo['store_id'], $merchantId);
foreach ($methods as $key => $value) {
if ($value['method'] == "voucher") {
unset($methods[$key]);
}
}
$methods = array_values($methods);
return [ return [
'order' => $orderInfo, 'order' => $orderInfo,
'personal' => $userInfo, 'personal' => $userInfo,

@ -80,7 +80,7 @@ class Payment extends BaseService
public function orderPay(?int $planId = null, string $customMoney = null, array $extra = []): array public function orderPay(?int $planId = null, string $customMoney = null, array $extra = []): array
{ {
// 创建余额订单信息 // 创建余额订单信息
$this->orderInfo = $this->createOrder($planId, $customMoney); $this->orderInfo = $this->createOrder($planId, $customMoney, $extra);
// 构建第三方支付请求的参数 // 构建第三方支付请求的参数
$payment = $this->unifiedorder($extra); $payment = $this->unifiedorder($extra);
// 记录第三方交易信息 // 记录第三方交易信息
@ -99,10 +99,10 @@ class Payment extends BaseService
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
private function createOrder(?int $planId = null, string $customMoney = null): OrderModel private function createOrder(?int $planId = null, string $customMoney = null, array $extra = []): OrderModel
{ {
$model = new OrderModel; $model = new OrderModel;
if (!$model->createOrder($planId, $customMoney)) { if (!$model->createOrder($planId, $customMoney, $extra)) {
throwError($model->getError() ?: '创建充值订单失败'); throwError($model->getError() ?: '创建充值订单失败');
} }
$model['order_id'] = (int)$model['order_id']; $model['order_id'] = (int)$model['order_id'];
@ -151,7 +151,7 @@ class Payment extends BaseService
*/ */
private function recordPaymentTrade(array $payment): void private function recordPaymentTrade(array $payment): void
{ {
if ($this->method != PaymentMethodEnum::BALANCE) { if (!in_array($this->method, [PaymentMethodEnum::BALANCE, PaymentMethodEnum::VOUCHER])) {
PaymentTradeModel::record( PaymentTradeModel::record(
$this->orderInfo, $this->orderInfo,
$this->method, $this->method,

@ -38,6 +38,8 @@ class SyncGoodsToPerMinute extends Command
$sql = "SELECT * FROM `yoshop_goods` WHERE goods_id > " . $goods_id . " AND goods_id % ". $div . " = ". $mod ." AND update_time > ".$min_time." order by update_time asc LIMIT ".$limit; $sql = "SELECT * FROM `yoshop_goods` WHERE goods_id > " . $goods_id . " AND goods_id % ". $div . " = ". $mod ." AND update_time > ".$min_time." order by update_time asc LIMIT ".$limit;
$list = Db::query($sql); $list = Db::query($sql);
if (!$list) { if (!$list) {
sleep(mt_rand(5,10));
echo date("Y-m-d H:i:s").PHP_EOL;
return true; return true;
} }
$obj = new GoodsCateEs(); $obj = new GoodsCateEs();

@ -88,12 +88,12 @@ class Payment extends BaseModel
if (empty($merchantId)) { if (empty($merchantId)) {
$merchantId = 0; $merchantId = 0;
} }
//if (!$data = Cache::get("payment_{$storeId}_{$merchantId}")) { if (!$data = Cache::get("payment_{$storeId}_{$merchantId}")) {
if (true) { //if (true) {
// 获取所有支付方式 // 获取所有支付方式
$data = $model->dataByStorage($storeId, $defaultData, $merchantId); $data = $model->dataByStorage($storeId, $defaultData, $merchantId);
// 写入缓存中 // 写入缓存中
//Cache::tag('cache')->set("payment_{$storeId}_{$merchantId}", $data); Cache::tag('cache')->set("payment_{$storeId}_{$merchantId}", $data);
} }
// 重组缓存数据 (多维) // 重组缓存数据 (多维)
return static::reorganize2($defaultData, $data); return static::reorganize2($defaultData, $data);
@ -303,7 +303,22 @@ class Payment extends BaseModel
$methods = []; $methods = [];
foreach ($group['methods'] as $method) { foreach ($group['methods'] as $method) {
if ($method['method'] == PaymentMethodEnum::VOUCHER) { if ($method['method'] == PaymentMethodEnum::VOUCHER) {
$method['template'] = $this->getTemplateInfo($method['template_id']);
$detail = $this->getTemplateInfo($method['template_id']);
if (isset($detail['config']['voucher']['alipayQrCodeId']) && $detail['config']['voucher']['alipayQrCodeId']) {
$info = UploadFile::detail($detail['config']['voucher']['alipayQrCodeId']);
$detail['config']['voucher']['alipayQrcode'] = $info['preview_url'] ?? "";
}
if (isset($detail['config']['voucher']['quickpayQrCodeId']) && $detail['config']['voucher']['quickpayQrCodeId']) {
$info = UploadFile::detail($detail['config']['voucher']['quickpayQrCodeId']);
$detail['config']['voucher']['quickpayQrCode'] = $info['preview_url'] ?? "";
}
if (isset($detail['config']['voucher']['wechatQrCodeId']) && $detail['config']['voucher']['wechatQrCodeId']) {
$info = UploadFile::detail($detail['config']['voucher']['wechatQrCodeId']);
$detail['config']['voucher']['wechatQrCode'] = $info['preview_url'] ?? "";
}
$method['template'] = $detail;
} }
if ($method['is_enable'] && ($balance || $method['method'] !== PaymentMethodEnum::BALANCE)) { if ($method['is_enable'] && ($balance || $method['method'] !== PaymentMethodEnum::BALANCE)) {
$methods[] = $method; $methods[] = $method;

@ -60,6 +60,7 @@ class Setting extends BaseModel
public static function getItem(string $key, ?int $storeId = null): array public static function getItem(string $key, ?int $storeId = null): array
{ {
$data = static::getAll($storeId); $data = static::getAll($storeId);
return isset($data[$key]) ? $data[$key]['values'] : []; return isset($data[$key]) ? $data[$key]['values'] : [];
} }
@ -128,6 +129,7 @@ class Setting extends BaseModel
*/ */
public function defaultData(): array public function defaultData(): array
{ {
$model = new static;
return [ return [
'basic' => [ 'basic' => [
'key' => 'basic', 'key' => 'basic',
@ -136,7 +138,7 @@ class Setting extends BaseModel
// 是否启用H5端访问 // 是否启用H5端访问
'enabled' => true, 'enabled' => true,
// h5站点url [默认是当前访问的域名] // h5站点url [默认是当前访问的域名]
'baseUrl' => base_url(), 'baseUrl' => base_url()."mobile/#/?storeId=".$model::$storeId,
] ]
] ]
]; ];

@ -33,4 +33,43 @@ class Recharge extends Controller
$list = $model->getList($this->request->param()); $list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }
/**
* 充值订单详情
* @param int $rechargeOrderId
* @return Json
*/
public function detail(int $rechargeOrderId): Json
{
// 售后单详情
$model = new OrderModel;
$detail = $model->getDetail($rechargeOrderId);
if (!$detail) {
return $this->renderError('未找到该充值记录');
}
$detail->refuse_desc = $detail->refuse_desc ? htmlspecialchars_decode($detail->refuse_desc) : "";
return $this->renderSuccess(compact('detail'));
}
/**
* 商家审核充值
* @param int $rechargeOrderId
* @return Json
*/
public function audit(int $rechargeOrderId): Json
{
// 售后单详情
$model = OrderModel::detail($rechargeOrderId);
if ($model->isEmpty()) {
return $this->renderError('未找到该充值记录');
}
if ($model->audit_status > 0) {
return $this->renderError('已审核');
}
// 确认审核
if ($model->audit($rechargeOrderId, $this->postForm())) {
return $this->renderSuccess('操作成功');
}
return $this->renderError($model->getError() ?: '操作失败');
}
} }

@ -13,7 +13,13 @@ declare (strict_types=1);
namespace app\store\model\recharge; namespace app\store\model\recharge;
use app\common\model\recharge\Order as OrderModel; use app\common\model\recharge\Order as OrderModel;
use app\common\enum\order\refund\AuditStatus as AuditStatusEnum;
use app\common\enum\payment\Method as PaymentMethodEnum;
use app\common\enum\recharge\order\PayStatus as PayStatusEnum;
use app\api\model\User as UserModel;
use app\common\enum\user\balanceLog\Scene as SceneEnum;
use app\api\model\user\BalanceLog as BalanceLogModel;
use app\common\model\UploadFile;
/** /**
* 用户充值订单模型 * 用户充值订单模型
* Class Order * Class Order
@ -74,4 +80,70 @@ class Order extends OrderModel
} }
return $filter; return $filter;
} }
/**
* 获取售后单详情
* @param int $rechargeOrderId
* @return OrderRefund|false|null
*/
public function getDetail(int $rechargeOrderId)
{
$detail = static::detail($rechargeOrderId, [
'user','orderPlan',
]) ?: false;
if (!$detail) {
return $detail;
}
if ($detail->upload_images) {
$img_ids = json_decode($detail->upload_images, true);
$files = UploadFile::getFileList($img_ids);
$detail->upload_images = !$files->isEmpty() ? $files->toArray() : [];
}
return $detail;
}
/**
* 商家审核
* @param array $data
* @return bool
*/
public function audit(int $rechargeOrderId, array $data): bool
{
if ($data['audit_status'] == AuditStatusEnum::REJECTED && empty($data['refuse_desc'])) {
$this->error = '请输入拒绝原因';
return false;
}
$this->transaction(function () use ($data, $rechargeOrderId) {
if ($data['audit_status'] == AuditStatusEnum::REJECTED) {
$data['pay_status'] = PayStatusEnum::PENDING;
} elseif ($data['audit_status'] == AuditStatusEnum::REVIEWED) {
$data['pay_status'] = PayStatusEnum::SUCCESS;
$data['pay_method'] = PaymentMethodEnum::VOUCHER;
$data['pay_time'] = time();
}
// var_dump($data);
// exit();
// 更新售后单状态
$this->save($data);
// 同意售后申请, 记录退货地址
if ($data['audit_status'] == AuditStatusEnum::REVIEWED) {
$orderInfo = self::detail($rechargeOrderId);
//新增用户充值记录和给用户加余额
// 累积用户余额
UserModel::setIncBalance((int)$orderInfo['user_id'], (float)$orderInfo['actual_money']);
// 用户余额变动明细
BalanceLogModel::add(SceneEnum::RECHARGE, [
'user_id' => $orderInfo['user_id'],
'money' => $orderInfo['actual_money'],
'store_id' => empty($orderInfo['store_id'])?$this->getStoreId():$orderInfo['store_id'],
], ['order_no' => $orderInfo['order_no']],$orderInfo['store_id']);
}
});
return true;
}
} }

Loading…
Cancel
Save