Merge remote-tracking branch 'origin/v5.1.0dev' into v5.1.0dev

This commit is contained in:
evoxwht 2023-06-19 11:04:38 +08:00
commit 3343051c8a
5 changed files with 98 additions and 14 deletions

View File

@ -323,18 +323,42 @@ class StoreOrder extends AuthController
$data = $this->request->postMore([
['kuaidicom', ''],
['send_address', ''],
['address', ''],
['weight', ''],
['orderId', ''],
['service_type', ''],
['cart_ids', []],
]);
foreach ($data['cart_ids'] as $cart) {
if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) {
return app('json')->fail(400159);
$orderInfo = $this->services->get($data['orderId'], ['user_address', 'cart_id']);
if (!$orderInfo) {
return app('json')->fail('订单没有查询到');
}
$weight = '0';
if ($data['cart_ids']) {
$cartIds = array_column($data['cart_ids'], 'cart_id');
$cartList = app()->make(StoreOrderCartInfoServices::class)->getColumn([
['cart_id', 'in', $cartIds]
], 'cart_info', 'cart_id');
foreach ($data['cart_ids'] as $cart) {
if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) {
return app('json')->fail(400159);
}
if (isset($cartList[$cart['cart_id']])) {
$value = is_string($cartList[$cart['cart_id']]) ? json_decode($cartList[$cart['cart_id']], true) : $cartList[$cart['cart_id']];
$weightnew = bcmul($value['attrInfo']['weight'], (string)$cart['cart_num'], 2);
$weight = bcadd($weightnew, $weight, 2);
}
}
} else {
$orderCartInfoList = app()->make(StoreOrderCartInfoServices::class)->getCartInfoPrintProduct($data['orderId']);
foreach ($orderCartInfoList as $item) {
$weightnew = bcmul($item['attrInfo']['weight'], (string)$item['cart_num'], 2);
$weight = bcadd($weightnew, $weight, 2);
}
}
$data['address'] = $orderInfo['user_address'];
if ($weight > 0) {
$data['weight'] = $weight;
}
return app('json')->success($services->express()->getPrice($data));
}

View File

@ -180,7 +180,7 @@ class Express extends BaseExpress
throw new ApiException('收件地址必须填写');
}
$param = [
'kuaidi_num' => $data['kuaidicom'],
'kuaidicom' => $data['kuaidicom'],
'send_address' => $data['send_address'],
'address' => $data['address'] ?? '',
'weight' => $data['weight'] ?? '',

View File

@ -28438,6 +28438,7 @@ CREATE TABLE IF NOT EXISTS `eb_store_order` (
`pay_type` varchar(32) NOT NULL DEFAULT '' COMMENT '支付方式',
`add_time` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '创建时间',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款)',
`is_stock_up` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否备货中',
`refund_status` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0 未退款 1 申请中 2 已退款',
`refund_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '退款申请类型',
`refund_express` varchar(255) NOT NULL DEFAULT '' COMMENT '退货快递单号',

View File

@ -502,6 +502,17 @@ export function otherBatchDelivery(data) {
data,
});
}
/**
* @description 商家寄件金额计算
* @param {Object} param data {Object} 传值参数
*/
export function orderPrice(data) {
return request({
url: 'order/price',
method: 'post',
data,
});
}
/**
* @description 重新执行
* @param {Object} param data {Object} 传值参数

View File

@ -18,9 +18,9 @@
</FormItem>
<FormItem v-if="formItem.type == 1" v-show="export_open" label="发货类型:">
<RadioGroup v-model="formItem.express_record_type" @on-change="changeExpress">
<Radio label="1">手动填写</Radio>
<Radio label="2">电子面单打印</Radio>
<Radio label="3">商家寄件</Radio>
<Radio label="1">录入单号</Radio>
<Radio label="2">电子面单打印</Radio>
</RadioGroup>
</FormItem>
<div>
@ -40,6 +40,11 @@
>
</Select>
</FormItem>
<FormItem label="快递业务类型:" v-if="formItem.type == 1 && formItem.express_record_type == 3">
<Select v-model="formItem.service_type" filterable placeholder="请选择业务类型" style="width: 80%">
<Option v-for="item in serviceTypeList" :value="item" :key="item">{{ item }}</Option>
</Select>
</FormItem>
<FormItem v-if="formItem.express_record_type === '1' && formItem.type == 1" label="快递单号:">
<Input v-model="formItem.delivery_id" placeholder="请输入快递单号" style="width: 80%"></Input>
<div class="trips" v-if="formItem.delivery_name == '顺丰速运'">
@ -152,6 +157,9 @@
</template>
</i-table>
</FormItem>
<FormItem label="寄件金额计算:">
<Button @click="watchPrice">立即计算</Button>
</FormItem>
</div>
</Form>
<div slot="footer">
@ -177,6 +185,7 @@ import {
orderSheetInfo,
splitCartInfo,
kuaidiComsList,
orderPrice,
} from '@/api/order';
import printJS from 'print-js';
export default {
@ -192,6 +201,10 @@ export default {
orderId(val) {
if (this.virtual_type == 3) this.formItem.type = '3';
},
modals(newVal) {
if (newVal) {
}
},
},
data() {
return {
@ -200,7 +213,7 @@ export default {
splitSwitch: true,
formItem: {
type: '1',
express_record_type: '1',
express_record_type: '3',
delivery_name: '',
delivery_id: '',
express_temp_id: '',
@ -209,6 +222,7 @@ export default {
to_addr: '',
sh_delivery: '',
fictitious_content: '',
service_type: '',
day_type: 0,
},
modals: false,
@ -280,9 +294,38 @@ export default {
},
],
selectData: [],
serviceTypeList: [],
};
},
mounted() {
this.kuaidiComsList(1);
let delData;
if (localStorage.getItem('DELIVERY_DATA')) delData = JSON.parse(localStorage.getItem('DELIVERY_DATA'));
if (delData) {
this.formItem.delivery_name = delData.delivery_name;
this.formItem.delivery_code = delData.delivery_code;
}
},
methods: {
watchPrice() {
console.log(1111);
let data = {
kuaidicom: this.formItem.delivery_code,
send_address: this.formItem.to_addr,
orderId: this.orderId,
service_type: this.formItem.service_type,
cart_ids: [],
};
this.selectData.forEach((v) => {
data.cart_ids.push({
cart_id: v.cart_id,
cart_num: v.num || v.surplus_num,
});
});
orderPrice(data).then((res) => {
console.log(res);
});
},
selectOne(data) {
this.selectData = data;
},
@ -350,22 +393,22 @@ export default {
case '3':
this.formItem.delivery_name = '';
this.formItem.delivery_id = '';
this.kuaidiComsList();
break;
default:
break;
}
},
kuaidiComsList() {
kuaidiComsList(status) {
kuaidiComsList().then((res) => {
console.log(res);
this.kuaidiExpress = res.data;
if (this.formItem.delivery_name) this.expressChange(this.formItem.delivery_name);
});
},
reset() {
this.formItem = {
type: '1',
express_record_type: '1',
express_record_type: '3',
delivery_name: '',
delivery_id: '',
express_temp_id: '',
@ -375,6 +418,7 @@ export default {
to_addr: '',
sh_delivery: '',
fictitious_content: '',
service_type: '',
};
},
// 物流公司列表
@ -447,6 +491,7 @@ export default {
.then((res) => {
this.modals = false;
this.$Message.success(res.msg);
localStorage.setItem('DELIVERY_DATA', JSON.stringify(this.formItem));
this.$emit('submitFail');
this.reset();
this.splitSwitch = false;
@ -460,6 +505,7 @@ export default {
.then(async (res) => {
this.modals = false;
this.$Message.success(res.msg);
localStorage.setItem('DELIVERY_DATA', JSON.stringify(this.formItem));
this.splitSwitch = false;
this.$emit('submitFail');
this.reset();
@ -483,6 +529,7 @@ export default {
},
// 电子面单列表
expressChange(value) {
this.formItem.service_type = '';
let expressItem = (this.formItem.express_record_type == '3' ? this.kuaidiExpress : this.express).find((item) => {
return item.value === value;
});
@ -490,6 +537,7 @@ export default {
if (expressItem === undefined) {
return;
}
this.serviceTypeList = expressItem.types;
this.formItem.delivery_code = expressItem.code;
if (this.formItem.express_record_type === '2') {
this.expressTemp = [];
@ -543,7 +591,7 @@ export default {
if (!this.export_open) {
this.formItem.express_record_type = '1';
}
this.formItem.to_addr = data.to_add;
// this.formItem.to_addr = data.to_add;
})
.catch((err) => {
this.$Message.error(err.msg);