feat: 添加阿里云短信服务支持并优化验证码逻辑

- 引入 alibabacloud/dysmsapi-20170525 依赖,集成阿里云短信服务
- 将短信验证码从6位改为4位,优化用户体验
- 添加聚水潭商品按时间范围同步功能,支持分页拉取
- 增强Cron任务异常处理,添加错误日志记录
- 修复系统附件服务中图片路径处理逻辑
- 更新阿里云SDK相关组件至最新版本
- 添加think-trace调试扩展,便于问题排查
- 优化跨域中间件,使用str_contains替代strpos
This commit is contained in:
2026-04-30 15:19:40 +08:00
parent 0334fef6c1
commit c7f85ffbda
565 changed files with 59742 additions and 3391 deletions

View File

@@ -80,6 +80,12 @@ class OrderServices
$biz = array_merge($biz, $this->getAddress($order['user_address']));
Log::info('jst.orders_upload.request ' . json_encode([
'api' => 'open/jushuitan/orders/upload',
'oid' => $oid,
'biz' => $biz,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
$num = 3;
for ($i = $num; $i >= 0; $i--) {
if ($i <= 0) {
@@ -544,7 +550,7 @@ class OrderServices
public function getShopId(int $erpShopId): int
{
if ($erpShopId < 1) {
$erpShopId = sys_config('jst_default_shopid');
$erpShopId = (int)app('sysConfig')->get('jst_default_shopid');
}
return (int)$erpShopId;

View File

@@ -727,6 +727,19 @@ class StoreOrderRefundServices extends BaseServices
OrderStatusJob::dispatch([$order['id'], 'refund_price', ['change_message' => '退款给用户:' . bcadd($online_refund_amount, $yue_refund_amount, 2) . '元; ' . $admin, 'change_manager_id' => request()->adminId(), 'change_manager_type' => 'admin']]);
return $order;
});
if ($order['private_bind_id'] && (int)$order['private_phone_status'] === 1 && $order['user_phone']) {
try {
$privacyPhoneServices = app()->make(\app\services\other\PrivacyPhoneServices::class);
if ($privacyPhoneServices->unbindForOrder((string)$order['user_phone'], (string)$order['private_bind_id'])) {
$this->storeOrderServices->update($order['id'], ['private_phone_status' => 0]);
}
} catch (\Throwable $e) {
\think\facade\Log::error('退款解绑隐私小号失败 order_id={order_id} error={error}', [
'order_id' => $order['id'],
'error' => $e->getMessage(),
]);
}
}
//订单同意退款事件
event('order.refund', [$refundData, $order, 'order_refund', (int)$id]);
return true;

View File

@@ -2027,6 +2027,19 @@ HTML;
throw new ValidateException('订单号' . $order['order_id'] . ',取消订单失败');
}
});
if ($order['private_bind_id'] && (int)$order['private_phone_status'] === 1 && $order['user_phone']) {
try {
$privacyPhoneServices = app()->make(\app\services\other\PrivacyPhoneServices::class);
if ($privacyPhoneServices->unbindForOrder((string)$order['user_phone'], (string)$order['private_bind_id'])) {
$this->dao->update($order['id'], ['private_phone_status' => 0]);
}
} catch (\Throwable $e) {
\think\facade\Log::error('取消订单解绑隐私小号失败 order_id={order_id} error={error}', [
'order_id' => $order['id'],
'error' => $e->getMessage(),
]);
}
}
//订单取消事件
event('order.cancel', [$order]);
return true;
@@ -2139,7 +2152,12 @@ HTML;
public function getExportList(array $where, array $with = [], int $limit = 0)
{
if ($limit) {
[$page] = $this->getPageValue();
$page = 1;
if (!empty($where['id'])) {
$page = 1;
} else {
[$page] = $this->getPageValue();
}
} else {
[$page, $limit] = $this->getPageValue();
}
@@ -2151,10 +2169,17 @@ HTML;
foreach ($list as &$item) {
/** @var StoreOrderCartInfoServices $orderCart */
$orderCart = app()->make(StoreOrderCartInfoServices::class);
$_info = $orderCart->getCartColunm(['oid' => $item['id']], 'cart_info', 'unique');
$_info = $orderCart->getCartColunm(['oid' => $item['id']], 'cart_id,type,relation_id,is_gift,cart_num,refund_num,cart_info', 'unique');
foreach ($_info as $k => $v) {
$cart_info = is_string($v) ? json_decode($v, true) : $v;
$cart_info = is_string($v['cart_info']) ? json_decode($v['cart_info'], true) : $v['cart_info'];
if (!isset($cart_info['productInfo'])) $cart_info['productInfo'] = [];
$cart_info['cart_num'] = $v['cart_num'] ?? ($cart_info['cart_num'] ?? 0);
$cart_info['refund_num'] = $v['refund_num'] ?? 0;
$cart_info['cart_id'] = $v['cart_id'] ?? ($cart_info['id'] ?? 0);
$cart_info['_relation_type'] = $v['type'] ?? 0;
$cart_info['_relation_id'] = $v['relation_id'] ?? 0;
$cart_info['is_gift'] = $v['is_gift'] ?? ($cart_info['is_gift'] ?? 0);
$cart_info['unique'] = $k;
$_info[$k] = $cart_info;
unset($cart_info);
}

View File

@@ -23,6 +23,35 @@ use think\facade\Log;
*/
class PrivacyPhoneServices extends BaseServices
{
/**
* 标准化AX小号:从后往前截取11位手机号
* @param string $number
* @return string
*/
private function normalizeAxNumber(string $number): string
{
if ($number === '') {
return '';
}
return strlen($number) > 11 ? substr($number, -11) : $number;
}
/**
* 日志上下文转字符串(ThinkPHP日志上下文仅支持占位符替换)
* @param mixed $value
* @return string
*/
private function toLogString($value): string
{
if (is_string($value)) {
return $value;
}
$json = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
return $json === false ? var_export($value, true) : $json;
}
/**
* API地址
*/
@@ -122,10 +151,10 @@ class PrivacyPhoneServices extends BaseServices
'decoded' => json_decode($response, true) ?? []
];
Log::info('隐私小号API请求', [
Log::info('隐私小号API请求 url={url} params={params} result={result}', [
'url' => $url,
'params' => $params,
'result' => $result
'params' => $this->toLogString($params),
'result' => $this->toLogString($result),
]);
return $result;
@@ -267,23 +296,33 @@ class PrivacyPhoneServices extends BaseServices
return $result;
}
$bindResult = $this->axBind($number, $realPhone);
$bindNumber = $this->normalizeAxNumber($number);
if (strlen($bindNumber) !== 11) {
Log::error('隐私小号格式异常 raw_number={raw_number} bind_number={bind_number}', [
'raw_number' => $number,
'bind_number' => $bindNumber,
]);
return $result;
}
$bindResult = $this->axBind($bindNumber, $realPhone);
if (!empty($bindResult['success']) && $bindResult['code'] == 200) {
$result = [
'user_phone' => $number,
'user_phone' => $bindNumber,
'bind_id' => $realPhone,
'status' => 1
];
Log::info('隐私小号绑定成功', [
'privacy_phone' => $number,
'real_phone' => $realPhone
Log::info('隐私小号绑定成功 privacy_phone={privacy_phone} real_phone={real_phone}', [
'privacy_phone' => $bindNumber,
'real_phone' => $realPhone,
]);
}
} catch (\Exception $e) {
Log::error('隐私小号绑定异常', [
Log::error('隐私小号绑定异常 real_phone={real_phone} ax_number={ax_number} error={error}', [
'real_phone' => $realPhone,
'error' => $e->getMessage()
'ax_number' => $bindNumber ?? ($number ?? ''),
'error' => $e->getMessage(),
]);
}
@@ -306,21 +345,30 @@ class PrivacyPhoneServices extends BaseServices
return false;
}
$unbindPhone = $this->normalizeAxNumber($privacyPhone);
if (strlen($unbindPhone) !== 11) {
Log::error('隐私小号格式异常 privacy_phone={privacy_phone} unbind_phone={unbind_phone}', [
'privacy_phone' => $privacyPhone,
'unbind_phone' => $unbindPhone,
]);
return false;
}
try {
$result = $this->unAxBind($privacyPhone, $realPhone);
$result = $this->unAxBind($unbindPhone, $realPhone);
if (!empty($result['success']) && $result['code'] == 200) {
Log::info('隐私小号解绑成功', [
'privacy_phone' => $privacyPhone,
'real_phone' => $realPhone
Log::info('隐私小号解绑成功 privacy_phone={privacy_phone} real_phone={real_phone}', [
'privacy_phone' => $unbindPhone,
'real_phone' => $realPhone,
]);
return true;
}
} catch (\Exception $e) {
Log::error('隐私小号解绑异常', [
'privacy_phone' => $privacyPhone,
Log::error('隐私小号解绑异常 privacy_phone={privacy_phone} real_phone={real_phone} error={error}', [
'privacy_phone' => $unbindPhone,
'real_phone' => $realPhone,
'error' => $e->getMessage()
'error' => $e->getMessage(),
]);
}

View File

@@ -14,10 +14,14 @@ namespace app\services\other\export;
use app\model\product\stock\StockRecord;
use app\services\BaseServices;
use app\jobs\system\ExportExcelJob;
use app\model\order\StoreOrderRefund;
use app\model\order\StoreOrderStatus;
use app\services\order\StoreOrderServices;
use app\services\pay\PayServices;
use app\services\product\label\StoreProductLabelServices;
use app\services\product\product\StoreDescriptionServices;
use app\services\product\sku\StoreProductAttrResultServices;
use app\services\supplier\SystemSupplierServices;
use app\services\user\UserServices;
use crmeb\services\SpreadsheetExcelService;
@@ -729,9 +733,11 @@ class ExportServices extends BaseServices
$header = ['订单ID', '订单编号', '性别', '电话', '收货人姓名', '收货人电话', '收货地址', '商品信息', '商品总数',
'总价格', '实际支付', '邮费', '会员优惠金额', '优惠卷金额', '积分抵扣金额', '支付状态', '支付时间', '订单状态', '下单时间', '用户备注'];
$header = [
'订单号', '订单类型', '订单状态', '下单时间', '买家姓名(uid)', '买家手机号', '收货地址', '商品名称', '商品数量', '商品金额合计', '邮费',
'会员优惠', '优惠券优惠', '积分抵扣', '活动优惠', '首单优惠', '改价优惠', '实付金额', '实付邮费', '支付方式',
'订单号', '订单类型', '订单状态', '下单时间', '买家姓名(uid)', '用户名称', '买家手机号', '收货地址',
'商品名称', '商品标签', 'SPU', '款式编码', '商品编号', '商品规格', '商品数量', '商品金额合计', '结算价', '商品来源',
'邮费', '会员优惠', '优惠券优惠', '积分抵扣', '活动优惠', '首单优惠', '改价优惠', '实付金额', '实付邮费', '支付方式',
'支付状态', '支付时间', '订单配送方式', '快递公司(单号)/送货人姓名(手机号)',
'退款状态', '退款金额', '分销员', '分销佣金', '订单发货时间',
// '售后状态', '售后类型', '售后件数', '退款金额', '退款时间', '退货备注'
];
$title = ['订单导出', '订单信息' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())];
@@ -744,6 +750,96 @@ class ExportServices extends BaseServices
$export = [];
$filekey = [];
if (!empty($data)) {
$userList = [];
$spreadList = [];
$orderStatusTime = [];
$refundCartMap = [];
$supplierList = [];
$labelNameMap = [];
if (!$type) {
$userServices = app()->make(UserServices::class);
$uids = array_values(array_unique(array_column($data, 'uid')));
$userList = $uids ? $userServices->getColumn([['uid', 'IN', $uids]], 'uid,nickname,spread_uid', 'uid') : [];
$spreadUids = $userList ? array_values(array_filter(array_unique(array_column($userList, 'spread_uid')))) : [];
$spreadList = $spreadUids ? $userServices->getColumn([['uid', 'IN', $spreadUids]], 'uid,nickname', 'uid') : [];
$orderIds = array_values(array_unique(array_column($data, 'id')));
$statusRows = StoreOrderStatus::whereIn('oid', $orderIds)
->whereIn('change_type', ['delivery', 'delivery_goods', 'delivery_part_split', 'delivery_split', 'delivery_fictitious'])
->field(['oid', 'change_type', 'change_time'])
->order('change_time desc')
->select()
->toArray();
foreach ($statusRows as $row) {
$oid = (int)$row['oid'];
$changeType = (string)$row['change_type'];
if (!isset($orderStatusTime[$oid][$changeType])) {
$orderStatusTime[$oid][$changeType] = (int)$row['change_time'];
}
}
$refundRows = StoreOrderRefund::whereIn('store_order_id', $orderIds)
->where('is_cancel', 0)
->where('is_del', 0)
->whereIn('refund_type', [0, 1, 2, 4, 5, 6])
->field(['store_order_id', 'refund_type', 'cart_info'])
->select()
->toArray();
foreach ($refundRows as $refund) {
$oid = (int)$refund['store_order_id'];
$refundType = (int)$refund['refund_type'];
$cartInfo = $refund['cart_info'] ?? [];
foreach ($cartInfo as $cart) {
$cartId = (int)($cart['id'] ?? 0);
$qty = (int)($cart['cart_num'] ?? 0);
if (!$cartId || !$qty) {
continue;
}
if (!isset($refundCartMap[$oid][$cartId])) {
$refundCartMap[$oid][$cartId] = ['refunding_qty' => 0, 'refunded_qty' => 0];
}
if ($refundType === 6) {
$refundCartMap[$oid][$cartId]['refunded_qty'] += $qty;
} else {
$refundCartMap[$oid][$cartId]['refunding_qty'] += $qty;
}
}
}
$supplierIds = [];
$labelIds = [];
foreach ($data as $o) {
foreach ($o['_info'] ?? [] as $cart) {
$productInfo = $cart['productInfo'] ?? [];
$supplierId = (int)($productInfo['supplier_id'] ?? 0);
if ($supplierId > 0) {
$supplierIds[$supplierId] = $supplierId;
} elseif ((int)($cart['_relation_type'] ?? 0) === 2 && (int)($cart['_relation_id'] ?? 0) > 0) {
$supplierId = (int)$cart['_relation_id'];
$supplierIds[$supplierId] = $supplierId;
}
$storeLabelId = $productInfo['store_label_id'] ?? [];
$storeLabelId = is_string($storeLabelId) ? array_map('intval', array_filter(explode(',', $storeLabelId))) : (is_array($storeLabelId) ? $storeLabelId : []);
foreach ($storeLabelId as $lid) {
$lid = (int)$lid;
if ($lid > 0) {
$labelIds[$lid] = $lid;
}
}
}
}
$supplierService = app()->make(SystemSupplierServices::class);
$supplierList = $supplierIds ? $supplierService->getColumn([['id', 'IN', array_values($supplierIds)]], 'id,supplier_name', 'id') : [];
$labelService = app()->make(StoreProductLabelServices::class);
$labelList = $labelIds ? $labelService->getLabelCache(array_values($labelIds), ['id', 'label_name'], false) : [];
foreach ($labelList as $label) {
if (isset($label['id'])) {
$labelNameMap[(int)$label['id']] = (string)($label['label_name'] ?? '');
}
}
}
$i = 0;
foreach ($data as $item) {
if (!$type) {
@@ -805,24 +901,9 @@ class ExportServices extends BaseServices
} else if ($item['paid'] == 1 && $item['refund_status'] == 3) {
$item['status_name'] = '部分退款';
}
$goodsName = [];
$vip_sum_price = 0;
foreach ($item['_info'] as $k => $v) {
$suk = '';
if (isset($v['productInfo']['attrInfo'])) {
if (isset($v['productInfo']['attrInfo']['suk'])) {
$suk = '(' . $v['productInfo']['attrInfo']['suk'] . ')';
}
}
if (isset($v['productInfo']['store_name'])) {
$goodsName[] = implode(' ',
[
$v['productInfo']['store_name'],
$suk,
"[{$v['cart_num']} * {$v['truePrice']}]",
]);
}
$vip_sum_price = bcadd((string)$vip_sum_price, bcmul($v['vip_truePrice'], $v['cart_num'] ? $v['cart_num'] : 1, 4), 2);
foreach ($item['_info'] as $v) {
$vip_sum_price = bcadd((string)$vip_sum_price, bcmul((string)($v['vip_truePrice'] ?? 0), (string)($v['cart_num'] ? $v['cart_num'] : 1), 4), 2);
}
// if ($item['sex'] == 1) $sex_name = '男';
// else if ($item['sex'] == 2) $sex_name = '女';
@@ -856,32 +937,134 @@ class ExportServices extends BaseServices
'send' => '配送',
default => '暂无',
};
$one_data = [
'order_id' => $item['order_id'],
'order_type' => $item['pink_name'] ?? '普通订单',
'status_name' => $item['status_name'] ?? '未知状态',
'add_time' => empty($item['add_time']) ? '' : date('Y-m-d H:i:s', (int)$item['add_time']),
'real_name' => $item['real_name'] . '(' . $item['uid'] . ')',
'user_phone' => $item['user_phone'],
'user_address' => $item['user_address'],
'goods_name' => $goodsName ? implode("\n", $goodsName) : '',
'total_num' => $item['total_num'],
'total_price' => $item['total_price'],
'total_postage' => $item['total_postage'],
'vip_sum_price' => $vip_sum_price,
'coupon_price' => $item['coupon_price'],
'deduction_price' => $item['deduction_price'] ?? 0,
'promotions_price' => $item['promotions_price'] ?? 0,
'first_order_price' => $item['first_order_price'] ?? 0,
'change_price' => $item['change_price'] ?? 0,
'pay_price' => $item['pay_price'],
'pay_postage' => $item['pay_postage'],
'pay_type_name' => $item['pay_type_name'],
'pay_status' => $item['paid'] ? '已支付' : '未支付',
'pay_time' => empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', (int)$item['pay_time']),
'delivery_type' => $delivery_type,
'delivery_info' => $item['delivery_name'] . '(' . $item['delivery_id'] . ')',
];
$orderLevelDeliveryTime = '';
$oid = (int)$item['id'];
$timeMap = $orderStatusTime[$oid] ?? [];
$deliveryTime = $timeMap['delivery'] ?? ($timeMap['delivery_goods'] ?? ($timeMap['delivery_part_split'] ?? ($timeMap['delivery_split'] ?? ($timeMap['delivery_fictitious'] ?? 0))));
if ($deliveryTime) {
$orderLevelDeliveryTime = date('Y-m-d H:i:s', $deliveryTime);
}
$currentUser = $userList[(int)$item['uid']] ?? [];
$userNickname = (string)($currentUser['nickname'] ?? '');
$spreadUid = (int)($currentUser['spread_uid'] ?? 0);
$spreadNickname = $spreadUid ? (string)($spreadList[$spreadUid]['nickname'] ?? '') : '';
if ($spreadUid && $spreadUid === (int)$item['uid'] && $spreadNickname !== '') {
$spreadNickname .= '(自购)';
}
foreach ($item['_info'] as $v) {
$productInfo = $v['productInfo'] ?? [];
$attrInfo = $productInfo['attrInfo'] ?? [];
$storeName = (string)($productInfo['store_name'] ?? '');
$suk = (string)($attrInfo['suk'] ?? '');
$productLabelNames = [];
if (!empty($productInfo['store_label']) && is_array($productInfo['store_label'])) {
foreach ($productInfo['store_label'] as $label) {
$name = (string)($label['label_name'] ?? ($label['label'] ?? ''));
if ($name !== '') {
$productLabelNames[] = $name;
}
}
} else {
$storeLabelId = $productInfo['store_label_id'] ?? [];
$storeLabelId = is_string($storeLabelId) ? array_map('intval', array_filter(explode(',', $storeLabelId))) : (is_array($storeLabelId) ? $storeLabelId : []);
foreach ($storeLabelId as $lid) {
$name = $labelNameMap[(int)$lid] ?? '';
if ($name !== '') {
$productLabelNames[] = $name;
}
}
}
$productLabelText = $productLabelNames ? implode(',', array_values(array_unique($productLabelNames))) : '';
$supplierId = (int)($productInfo['supplier_id'] ?? 0);
if (!$supplierId && (int)($v['_relation_type'] ?? 0) === 2) {
$supplierId = (int)($v['_relation_id'] ?? 0);
}
$productSource = $supplierId ? (string)($supplierList[$supplierId]['supplier_name'] ?? '') : '平台';
$cartId = (int)($v['cart_id'] ?? 0);
$refundedQty = (int)($refundCartMap[$oid][$cartId]['refunded_qty'] ?? 0);
$refundingQty = (int)($refundCartMap[$oid][$cartId]['refunding_qty'] ?? 0);
$refundQty = $refundedQty + $refundingQty;
$cartNum = (int)($v['cart_num'] ?? 0);
$truePrice = (string)($v['truePrice'] ?? 0);
$productAmount = bcmul($truePrice, (string)$cartNum, 2);
$refundStatus = '';
if ($refundQty > 0) {
if ($refundingQty > 0) {
$refundStatus = '退款中';
} else {
$refundStatus = $refundQty >= $cartNum ? '退款成功(全额退款)' : '退款成功(部分退款)';
}
}
$refundAmount = $refundQty > 0 ? bcmul($truePrice, (string)$refundQty, 2) : '';
$settlePrice = (string)($attrInfo['settle_price'] ?? 0);
$oneBrokerage = $v['one_brokerage'] ?? null;
if ($oneBrokerage === null) {
$oneBrokerage = bcmul((string)($attrInfo['brokerage'] ?? 0), (string)$cartNum, 2);
}
$twoBrokerage = $v['two_brokerage'] ?? null;
if ($twoBrokerage === null) {
$twoBrokerage = bcmul((string)($attrInfo['brokerage_two'] ?? 0), (string)$cartNum, 2);
}
$commission = bcadd((string)$oneBrokerage, (string)$twoBrokerage, 2);
$one_data = [
'order_id' => $item['order_id'],
'order_type' => $item['pink_name'] ?? '普通订单',
'status_name' => $item['status_name'] ?? '未知状态',
'add_time' => empty($item['add_time']) ? '' : date('Y-m-d H:i:s', (int)$item['add_time']),
'real_name' => $item['real_name'] . '(' . $item['uid'] . ')',
'user_nickname' => $userNickname,
'user_phone' => $item['user_phone'],
'user_address' => $item['user_address'],
'goods_name' => $storeName,
'goods_label' => $productLabelText,
'spu' => (string)($productInfo['spu'] ?? ''),
'style_code' => (string)($productInfo['code'] ?? ''),
'sku_code' => (string)($attrInfo['code'] ?? ''),
'goods_suk' => $suk,
'cart_num' => $cartNum,
'product_amount' => $productAmount,
'settle_price' => $settlePrice,
'product_source' => $productSource,
'total_postage' => $item['total_postage'],
'vip_sum_price' => $vip_sum_price,
'coupon_price' => $item['coupon_price'],
'deduction_price' => $item['deduction_price'] ?? 0,
'promotions_price' => $item['promotions_price'] ?? 0,
'first_order_price' => $item['first_order_price'] ?? 0,
'change_price' => $item['change_price'] ?? 0,
'pay_price' => $item['pay_price'],
'pay_postage' => $item['pay_postage'],
'pay_type_name' => $item['pay_type_name'],
'pay_status' => $item['paid'] ? '已支付' : '未支付',
'pay_time' => empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', (int)$item['pay_time']),
'delivery_type' => $delivery_type,
'delivery_info' => $item['delivery_name'] . '(' . $item['delivery_id'] . ')',
'refund_status' => $refundStatus,
'refund_amount' => $refundAmount,
'spread_nickname' => $spreadNickname,
'spread_commission' => $commission,
'delivery_time' => $orderLevelDeliveryTime,
];
if ($export_type == 1) {
$export[] = $one_data;
if ($i == 0) {
$filekey = array_keys($one_data);
}
} else {
$export[] = array_values($one_data);
}
$i++;
}
} else {
if (isset($item['pinkStatus']) && $item['pinkStatus'] != 2) {
continue;
@@ -937,15 +1120,17 @@ class ExportServices extends BaseServices
'pay_time' => $item['pay_time'] ? date('Y-m-d H:i:s', (int)$item['pay_time']) : '暂无',
];
}
if ($export_type == 1) {
$export[] = $one_data;
if ($i == 0) {
$filekey = array_keys($one_data);
if ($type) {
if ($export_type == 1) {
$export[] = $one_data;
if ($i == 0) {
$filekey = array_keys($one_data);
}
} else {
$export[] = array_values($one_data);
}
} else {
$export[] = array_values($one_data);
$i++;
}
$i++;
}
}
if ($export_type == 1) {

View File

@@ -797,6 +797,35 @@ class StoreProductServices extends BaseServices
return substr(implode('', array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8) . str_pad((string)mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
}
protected function createUniqueSpu(): string
{
$tries = 0;
do {
$spu = $this->createSpu();
$tries++;
} while ($tries < 20 && $this->dao->be(['spu' => $spu], 'spu'));
return $spu;
}
public function ensureSpu(int $productId): string
{
$spu = (string)$this->dao->value(['id' => $productId], 'spu');
if ($spu !== '') {
return $spu;
}
$spu = $this->createUniqueSpu();
$this->update($productId, ['spu' => $spu]);
return $spu;
}
public function ErpProductSave(array $data): int
{
if (!isset($data['spu']) || $data['spu'] === '') {
$data['spu'] = $this->createUniqueSpu();
}
return (int)$this->dao->ErpProductSave($data);
}
/**
* 新增编辑商品
* @param int $id
@@ -1531,7 +1560,7 @@ class StoreProductServices extends BaseServices
}
}
[$page, $limit] = $this->getPageValue();
$field = ['id,relation_id,type,pid,delivery_type,product_type,store_name,cate_id,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,stock,activity,ot_price,spec_type,recommend_image,unit_name,is_vip,vip_price,is_presale_product,is_vip_product,system_form_id,is_presale_product,presale_start_time,presale_end_time,is_limit,limit_num,video_open,video_link,freight,star,store_label_id,brand_id,min_qty'];
$field = ['id,spu,relation_id,type,pid,delivery_type,product_type,store_name,cate_id,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,stock,activity,ot_price,spec_type,recommend_image,unit_name,is_vip,vip_price,is_presale_product,is_vip_product,system_form_id,is_presale_product,presale_start_time,presale_end_time,is_limit,limit_num,video_open,video_link,freight,star,store_label_id,brand_id,min_qty'];
$list = $this->dao->getSearchList($where, $page, $limit, $field, 'sales desc,id desc', ['couponId']);
if ($list) {
/** @var MemberCardServices $memberCardService */

View File

@@ -31,15 +31,13 @@ class OrderStatisticServices extends BaseServices
$orderService = app()->make(StoreOrderServices::class);
$data['pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'supplier_id' => $supplier_id], 'pay_price', true);
$data['pay_count'] = $orderService->count(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'supplier_id' => $supplier_id]);
$times = explode('-', $where['time']);
if(count($times) > 1){
$times = [
'start_time'=>$times[0],
'end_time'=>$times[1] . ' 23:59:59'
];
$refundWhere = ['refund_type' => 6, 'time' => explode('-', $where['time']), 'is_cancel' => 0, 'is_del' => 0];
if ($supplier_id !== '') {
$refundWhere['supplier_id'] = $supplier_id;
}
$data['refund_price'] = app()->make(StoreOrderRefundServices::class)->sum(['refund_type' => 6, 'time' => explode('-', $where['time'])],'refund_price', true);
$data['refund_count'] = app()->make(StoreOrderRefundServices::class)->count(['refund_type' => 6, 'time' => explode('-', $where['time'])]);
$refundService = app()->make(StoreOrderRefundServices::class);
$data['refund_price'] = $refundService->sum($refundWhere, 'refund_price', true);
$data['refund_count'] = $refundService->count($refundWhere);
$data['coupon_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'supplier_id' => $supplier_id], 'coupon_price', true);
$data['coupon_count'] = $orderService->search(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'is_coupon' => 1, 'supplier_id' => $supplier_id])->count();
return $data;

View File

@@ -394,7 +394,7 @@ class SystemAdminServices extends BaseServices
$verifyCode = CacheService::get('code_' . $data['phone']);
if (!$verifyCode)
throw new AdminException('请先获取验证码');
$verifyCode = substr($verifyCode, 0, 6);
$verifyCode = substr($verifyCode, 0, 4);
if ($verifyCode != $data['code']) {
CacheService::delete('code_' . $data['phone']);
throw new AdminException('验证码错误');

View File

@@ -65,7 +65,7 @@ class SystemAttachmentServices extends BaseServices
if ($item['file_type'] == 1) {
if ($site_url) {
$item['satt_dir'] = (strpos($item['satt_dir'], $site_url) !== false || strstr($item['satt_dir'], 'http') !== false) ? $item['satt_dir'] : $site_url . $item['satt_dir'];
$item['att_dir'] = (strpos($item['att_dir'], $site_url) !== false || strstr($item['att_dir'], 'http') !== false) ? $item['satt_dir'] : $site_url . $item['att_dir'];
$item['att_dir'] = (strpos($item['att_dir'], $site_url) !== false || strstr($item['att_dir'], 'http') !== false) ? $item['att_dir'] : $site_url . $item['att_dir'];
}
}
$item['att_size'] = formatFileSize($item['att_size']);

View File

@@ -167,7 +167,7 @@ class LoginServices extends BaseServices
if (CacheService::get('code_' . $phone))
throw new ValidateException($time . '分钟内有效');
mt_srand();
$code = rand(100000, 999999);
$code = rand(1000, 9999);
$data['code'] = $code;
$data['time'] = $time;
$res = SmsJob::dispatch([$phone, $data, 'VERIFICATION_CODE_TIME']);