后台下单,目前传参和保存模版一致

This commit is contained in:
kuang.yife 2023-04-16 15:09:08 +08:00
parent 9791ab6530
commit 48e5101d9a
3 changed files with 86 additions and 62 deletions

View File

@ -1,6 +1,7 @@
package com.ghy.web.controller.order;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.order.domain.OrderTemplate;
import com.ghy.order.service.OrderTemplateService;
import lombok.extern.slf4j.Slf4j;
@ -21,11 +22,13 @@ public class OrderTemplateController extends BaseController {
@PostMapping("insert")
@ResponseBody
public int insert(@RequestBody OrderTemplate orderTemplate) {
public AjaxResult insert(@RequestBody OrderTemplate orderTemplate) {
Long userId = getUserId();
Assert.notNull(userId, "UserId is null !");
orderTemplate.setUserId(userId);
return orderTemplateService.insert(orderTemplate);
orderTemplate.setCreateBy(getLoginName());
orderTemplateService.insert(orderTemplate);
return AjaxResult.success();
}
@DeleteMapping("delete")

View File

@ -178,7 +178,7 @@
<select class="district form-control m-b" name="district" id="district" required onchange="selectRegion('district', 'street')"></select>
</div>
<div class="col-sm-3">
<select class="street form-control m-b" name="street" id="street" required></select>
<select class="street form-control m-b" name="streetId" id="streetId" required></select>
</div>
</div>
</div>
@ -441,7 +441,28 @@
}
function submitOrder() {
if ($.validate.form()) {
var data = $("#addTemplateForm").serializeArray();
var params= {};
data.forEach(function (item){
params[item.name] = item.value;
});
$.ajax({
type: "POST",
dataType:"json",
url: ctx + "order/sys/order",
data: JSON.stringify(params),
contentType: 'application/json',
success: function (result) {
if (result.code == web_status.SUCCESS) {
$.modal.msgSuccess("提交成功")
} else {
$.modal.msgError("请求失败")
}
}
})
}
}
function addTemplate() {

View File

@ -36,26 +36,26 @@
<update id="update" parameterType="com.ghy.order.domain.OrderTemplate">
UPDATE order_template
<set>
<if test="templateName != null and templateName != 0">template_name = #{templateName},</if>
<if test="goodsBrand != null and goodsBrand != 0">goods_brand = #{goodsBrand},</if>
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">video_url = #{videoUrl},</if>
<if test="imageUrl != null and imageUrl != 0">image_url = #{imageUrl},</if>
<if test="addressId != null and addressId != 0">address_id = #{addressId},</if>
<if test="streetId != null and streetId != 0">street_id = #{streetId},</if>
<if test="fullAddress != null and fullAddress != 0">full_address = #{fullAddress},</if>
<if test="customerName != null and customerName != 0">customer_name = #{customerName},</if>
<if test="customerPhone != null and customerPhone != 0">customer_phone = #{customerPhone},</if>
<if test="orderMode != null and orderMode != 0">order_mode = #{orderMode},</if>
<if test="price != null and price != 0">price = #{price},</if>
<if test="agencyFund != null and agencyFund != 0">agency_fund = #{agencyFund},</if>
<if test="informationFee != null and informationFee != 0">information_fee = #{informationFee},</if>
<if test="bonus != null and bonus != 0">bonus = #{bonus},</if>
<if test="logisticsCode != null and logisticsCode != 0">logistics_code = #{logisticsCode},</if>
<if test="needWagon != null and needWagon != 0">need_wagon = #{needWagon},</if>
<if test="needCarry != null and needCarry != 0">need_carry = #{needCarry},</if>
<if test="floor != null and floor != 0">floor = #{floor},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="templateName != null">template_name = #{templateName},</if>
<if test="goodsBrand != null">goods_brand = #{goodsBrand},</if>
<if test="goodsSpecification != null">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null">video_url = #{videoUrl},</if>
<if test="imageUrl != null">image_url = #{imageUrl},</if>
<if test="addressId != null">address_id = #{addressId},</if>
<if test="streetId != null">street_id = #{streetId},</if>
<if test="fullAddress != null">full_address = #{fullAddress},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="customerPhone != null">customer_phone = #{customerPhone},</if>
<if test="orderMode != null">order_mode = #{orderMode},</if>
<if test="price != null">price = #{price},</if>
<if test="agencyFund != null">agency_fund = #{agencyFund},</if>
<if test="informationFee != null ">information_fee = #{informationFee},</if>
<if test="bonus != null">bonus = #{bonus},</if>
<if test="logisticsCode != null">logistics_code = #{logisticsCode},</if>
<if test="needWagon != null">need_wagon = #{needWagon},</if>
<if test="needCarry != null">need_carry = #{needCarry},</if>
<if test="floor != null">floor = #{floor},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}
@ -64,47 +64,47 @@
<insert id="insert" parameterType="com.ghy.order.domain.OrderTemplate" useGeneratedKeys="true" keyProperty="id">
INSERT INTO order_template(
user_id,
<if test="templateName != null and templateName != 0">template_name,</if>
<if test="goodsBrand != null and goodsBrand != 0">goods_brand,</if>
<if test="goodsSpecification != null and goodsSpecification != 0">goods_specification = #{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">video_url,</if>
<if test="imageUrl != null and imageUrl != 0">image_url,</if>
<if test="addressId != null and addressId != 0">address_id,</if>
<if test="streetId != null and streetId != 0">street_id,</if>
<if test="fullAddress != null and fullAddress != 0">full_address,</if>
<if test="customerName != null and customerName != 0">customer_name,</if>
<if test="customerPhone != null and customerPhone != 0">customer_phone,</if>
<if test="orderMode != null and orderMode != 0">order_mode,</if>
<if test="price != null and price != 0">price,</if>
<if test="agencyFund != null and agencyFund != 0">agency_fund,</if>
<if test="informationFee != null and informationFee != 0">information_fee,</if>
<if test="bonus != null and bonus != 0">bonus,</if>
<if test="logisticsCode != null and logisticsCode != 0">logistics_code,</if>
<if test="needWagon != null and needWagon != 0">need_wagon,</if>
<if test="needCarry != null and needCarry != 0">need_carry,</if>
<if test="floor != null and floor != 0">floor,</if>
<if test="templateName != null">template_name,</if>
<if test="goodsBrand != null ">goods_brand,</if>
<if test="goodsSpecification != null ">goods_specification,</if>
<if test="videoUrl != null ">video_url,</if>
<if test="imageUrl != null ">image_url,</if>
<if test="addressId != null ">address_id,</if>
<if test="streetId != null ">street_id,</if>
<if test="fullAddress != null ">full_address,</if>
<if test="customerName != null ">customer_name,</if>
<if test="customerPhone != null ">customer_phone,</if>
<if test="orderMode != null">order_mode,</if>
<if test="price != null">price,</if>
<if test="agencyFund != null">agency_fund,</if>
<if test="informationFee != null">information_fee,</if>
<if test="bonus != null">bonus,</if>
<if test="logisticsCode != null">logistics_code,</if>
<if test="needWagon != null">need_wagon,</if>
<if test="needCarry != null">need_carry,</if>
<if test="floor != null ">floor,</if>
create_time
)VALUES(
#{userId},
<if test="templateName != null and templateName != 0">#{templateName},</if>
<if test="goodsBrand != null and goodsBrand != 0">#{goodsBrand},</if>
<if test="goodsSpecification != null and goodsSpecification != 0">#{goodsSpecification},</if>
<if test="videoUrl != null and videoUrl != 0">#{videoUrl},</if>
<if test="imageUrl != null and imageUrl != 0">#{imageUrl},</if>
<if test="addressId != null and addressId != 0">#{addressId},</if>
<if test="streetId != null and streetId != 0">#{streetId},</if>
<if test="fullAddress != null and fullAddress != 0">#{fullAddress},</if>
<if test="customerName != null and customerName != 0">#{customerName},</if>
<if test="customerPhone != null and customerPhone != 0">#{customerPhone},</if>
<if test="orderMode != null and orderMode != 0">#{orderMode},</if>
<if test="price != null and price != 0">#{price},</if>
<if test="agencyFund != null and agencyFund != 0">#{agencyFund},</if>
<if test="informationFee != null and informationFee != 0">#{informationFee},</if>
<if test="bonus != null and bonus != 0">#{bonus},</if>
<if test="logisticsCode != null and logisticsCode != 0">#{logisticsCode},</if>
<if test="needWagon != null and needWagon != 0">#{needWagon},</if>
<if test="needCarry != null and needCarry != 0">#{needCarry},</if>
<if test="floor != null and floor != 0">#{floor},</if>
<if test="templateName != null ">#{templateName},</if>
<if test="goodsBrand != null">#{goodsBrand},</if>
<if test="goodsSpecification != null">#{goodsSpecification},</if>
<if test="videoUrl != null ">#{videoUrl},</if>
<if test="imageUrl != null">#{imageUrl},</if>
<if test="addressId != null">#{addressId},</if>
<if test="streetId != null">#{streetId},</if>
<if test="fullAddress != null">#{fullAddress},</if>
<if test="customerName != null">#{customerName},</if>
<if test="customerPhone != null">#{customerPhone},</if>
<if test="orderMode != null">#{orderMode},</if>
<if test="price != null">#{price},</if>
<if test="agencyFund != null">#{agencyFund},</if>
<if test="informationFee != null">#{informationFee},</if>
<if test="bonus != null">#{bonus},</if>
<if test="logisticsCode != null">#{logisticsCode},</if>
<if test="needWagon != null">#{needWagon},</if>
<if test="needCarry != null">#{needCarry},</if>
<if test="floor != null">#{floor},</if>
SYSDATE()
)
</insert>
@ -112,7 +112,7 @@
<select id="select" parameterType="com.ghy.order.domain.OrderTemplate" resultMap="ColumnMap">
<include refid="selectColumns"/>
<where>
<if test="userId != null and userId != 0">
<if test="userId != null">
AND user_id = #{userId}
</if>
</where>