chore: 新增epay和cos插件相关类库及配置文件
- 新增epay v2、v3、v3new版本的支付类库及证书文件 - 新增cos云存储类库文件 - 调整文件上传保存格式为按分类存储 - 修复会员、规则、类目等语言翻译键名 - 新增小程序图标等静态资源文件
这个提交包含在:
@@ -471,6 +471,104 @@ class Merchant extends Base
|
||||
/**
|
||||
* 当前用户商家档案:主账号直接匹配,关联账号通过绑定关系匹配
|
||||
*/
|
||||
/**
|
||||
* 商户端:Excel 或结构化数据一键批量解析下单
|
||||
* @ApiMethod (POST)
|
||||
*/
|
||||
public function importBatch()
|
||||
{
|
||||
$merchant = $this->requireMerchant();
|
||||
$items = $this->request->post('items/a', []);
|
||||
if (empty($items)) {
|
||||
$items = $this->request->post('orders/a', []);
|
||||
}
|
||||
if (empty($items) || !is_array($items)) {
|
||||
$this->error('导入数据不能为空');
|
||||
}
|
||||
|
||||
$globalServiceId = (int)$this->request->post('service_id', 1);
|
||||
$svc = Db::name('service')->where('id', $globalServiceId)->find();
|
||||
$defaultServiceName = $svc ? $svc['name'] : '家居安装';
|
||||
$defaultPrice = $svc && (float)$svc['base_price'] > 0 ? (float)$svc['base_price'] : 80.00;
|
||||
|
||||
$ordersCreated = [];
|
||||
$totalAmount = 0.00;
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$batchNo = 'MB' . date('YmdHis') . mt_rand(1000, 9999);
|
||||
foreach ($items as $idx => $item) {
|
||||
$contact = trim((string)(isset($item['contact']) ? $item['contact'] : '买家'));
|
||||
$mobile = trim((string)(isset($item['mobile']) ? $item['mobile'] : ''));
|
||||
$address = trim((string)(isset($item['address']) ? $item['address'] : ''));
|
||||
$serviceName = trim((string)(isset($item['service_name']) ? $item['service_name'] : $defaultServiceName));
|
||||
$goodsModel = trim((string)(isset($item['goods_model']) ? $item['goods_model'] : ''));
|
||||
$goodsNum = max(1, (int)(isset($item['goods_num']) ? $item['goods_num'] : (isset($item['num']) ? $item['num'] : 1)));
|
||||
|
||||
if (!$mobile || !$address) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$orderNo = date('YmdHis') . mt_rand(100000, 999999);
|
||||
$singlePrice = isset($item['price']) && (float)$item['price'] > 0 ? (float)$item['price'] : $defaultPrice;
|
||||
$baseAmount = round($singlePrice * $goodsNum, 2);
|
||||
$verifyCode = (string)mt_rand(100000, 999999);
|
||||
|
||||
$orderId = Db::name('order')->insertGetId([
|
||||
'order_no' => $orderNo,
|
||||
'user_id' => $this->uid(),
|
||||
'service_id' => $globalServiceId,
|
||||
'service_name' => $serviceName,
|
||||
'goods_model' => $goodsModel,
|
||||
'goods_num' => $goodsNum,
|
||||
'contact' => $contact,
|
||||
'mobile' => $mobile,
|
||||
'address' => $address,
|
||||
'province' => isset($item['province']) ? $item['province'] : '贵州省',
|
||||
'city' => isset($item['city']) ? $item['city'] : '贵阳市',
|
||||
'district' => isset($item['district']) ? $item['district'] : '南明区',
|
||||
'floor' => isset($item['floor']) ? (int)$item['floor'] : 1,
|
||||
'has_elevator' => isset($item['elevator']) ? (int)$item['elevator'] : 1,
|
||||
'base_amount' => $baseAmount,
|
||||
'total_amount' => $baseAmount,
|
||||
'pay_amount' => $baseAmount,
|
||||
'status' => OrderStatus::PENDING_ACCEPT,
|
||||
'pay_status' => 1,
|
||||
'pay_time' => time(),
|
||||
'verify_code' => $verifyCode,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
|
||||
Db::name('merchant_order')->insert([
|
||||
'merchant_id' => (int)$merchant['id'],
|
||||
'order_id' => $orderId,
|
||||
'batch_no' => $batchNo,
|
||||
'createtime' => time(),
|
||||
]);
|
||||
|
||||
$ordersCreated[] = [
|
||||
'order_id' => $orderId,
|
||||
'order_no' => $orderNo,
|
||||
'contact' => $contact,
|
||||
'amount' => $baseAmount
|
||||
];
|
||||
$totalAmount += $baseAmount;
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error('批量导入失败:' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->success('批量下单导入成功!', [
|
||||
'batch_no' => $batchNo,
|
||||
'count' => count($ordersCreated),
|
||||
'total_amount' => round($totalAmount, 2),
|
||||
'orders' => $ordersCreated,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function merchantInfo()
|
||||
{
|
||||
$merchant = Db::name('merchant')->where('user_id', $this->uid())->find();
|
||||
|
||||
在新工单中引用
屏蔽一个用户