Merge branch 'master' of https://gitee.com/op-souls/ghy-all
This commit is contained in:
commit
83be387381
|
|
@ -1,7 +1,6 @@
|
||||||
package com.ghy.web.controller.goods;
|
package com.ghy.web.controller.goods;
|
||||||
|
|
||||||
import com.ghy.common.annotation.Log;
|
import com.ghy.common.annotation.Log;
|
||||||
import com.ghy.common.constant.UserConstants;
|
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.core.page.TableDataInfo;
|
import com.ghy.common.core.page.TableDataInfo;
|
||||||
|
|
@ -86,11 +85,6 @@ public class GoodsController extends BaseController {
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(@Validated Goods goods) {
|
public AjaxResult addSave(@Validated Goods goods) {
|
||||||
if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods))) {
|
|
||||||
return error("新增商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
|
||||||
} else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods))) {
|
|
||||||
return error("新增商品'" + goods.getGoodsName() + "'失败,商品编码已存在");
|
|
||||||
}
|
|
||||||
goods.setCreateBy(getLoginName());
|
goods.setCreateBy(getLoginName());
|
||||||
goods.setDeptId(getSysUser().getDeptId());
|
goods.setDeptId(getSysUser().getDeptId());
|
||||||
return toAjax(goodsService.insertGoods(goods));
|
return toAjax(goodsService.insertGoods(goods));
|
||||||
|
|
@ -102,6 +96,8 @@ public class GoodsController extends BaseController {
|
||||||
@RequiresPermissions("goods:goods:edit")
|
@RequiresPermissions("goods:goods:edit")
|
||||||
@GetMapping("/edit/{goodsId}")
|
@GetMapping("/edit/{goodsId}")
|
||||||
public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap) {
|
public String edit(@PathVariable("goodsId") Long goodsId, ModelMap mmap) {
|
||||||
|
Long parentId = ShiroUtils.getSysUser().getParentId();
|
||||||
|
mmap.put("deptGoodsCategories", deptGoodsCategoryService.list(parentId));
|
||||||
mmap.put("goods", goodsService.selectById(goodsId));
|
mmap.put("goods", goodsService.selectById(goodsId));
|
||||||
return PREFIX + "/edit";
|
return PREFIX + "/edit";
|
||||||
}
|
}
|
||||||
|
|
@ -114,11 +110,6 @@ public class GoodsController extends BaseController {
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(@Validated Goods goods) {
|
public AjaxResult editSave(@Validated Goods goods) {
|
||||||
if (UserConstants.GOODS_NAME_NOT_UNIQUE.equals(goodsService.checkGoodsNameUnique(goods))) {
|
|
||||||
return error("修改商品'" + goods.getGoodsName() + "'失败,商品名称已存在");
|
|
||||||
} else if (UserConstants.GOODS_CODE_NOT_UNIQUE.equals(goodsService.checkGoodsCodeUnique(goods))) {
|
|
||||||
return error("修改商品'" + goods.getGoodsCode() + "'失败,商品编码已存在");
|
|
||||||
}
|
|
||||||
goods.setUpdateBy(getLoginName());
|
goods.setUpdateBy(getLoginName());
|
||||||
return toAjax(goodsService.updateGoods(goods));
|
return toAjax(goodsService.updateGoods(goods));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,24 @@ package com.ghy.web.controller.order;
|
||||||
|
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
import com.ghy.common.utils.StringUtils;
|
||||||
|
import com.ghy.customer.domain.Customer;
|
||||||
|
import com.ghy.customer.service.CustomerService;
|
||||||
|
import com.ghy.goods.service.GoodsService;
|
||||||
|
import com.ghy.order.domain.OrderMaster;
|
||||||
|
import com.ghy.order.request.AppOrderRequest;
|
||||||
|
import com.ghy.order.service.OrderDetailService;
|
||||||
|
import com.ghy.order.service.OrderMasterService;
|
||||||
|
import com.ghy.payment.service.FinancialDetailService;
|
||||||
|
import com.ghy.payment.service.FinancialMasterService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author clunt
|
* @author clunt
|
||||||
* 下单接口
|
* 下单接口
|
||||||
|
|
@ -14,19 +28,46 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@RequestMapping("/order")
|
@RequestMapping("/order")
|
||||||
public class OrderController extends BaseController {
|
public class OrderController extends BaseController {
|
||||||
|
|
||||||
@PostMapping("/app")
|
@Autowired
|
||||||
public AjaxResult appOrder(){
|
private CustomerService customerService;
|
||||||
//TODO 校验商品信息(库存)
|
|
||||||
|
|
||||||
//TODO 计算商品费用和运费汇总
|
@Autowired
|
||||||
|
private GoodsService goodsService;
|
||||||
|
|
||||||
//TODO 生成主单
|
@Autowired
|
||||||
|
private OrderMasterService orderMasterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderDetailService orderDetailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FinancialMasterService financialMasterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FinancialDetailService financialDetailService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/server/app")
|
||||||
|
public AjaxResult appOrder(AppOrderRequest appOrderRequest){
|
||||||
|
// 校验用户信息
|
||||||
|
Customer customer = customerService.selectByCustomerId(appOrderRequest.getCustomerId());
|
||||||
|
if(StringUtils.isNull(customer)){
|
||||||
|
return AjaxResult.error("用户不存在!");
|
||||||
|
}
|
||||||
|
// 校验商品信息(库存)
|
||||||
|
boolean flag = goodsService.checkStore(appOrderRequest.getGoodsList());
|
||||||
|
if(!flag){
|
||||||
|
return AjaxResult.error("库存不足!");
|
||||||
|
}
|
||||||
|
// 计算商品费用
|
||||||
|
BigDecimal totalPay = goodsService.calculate(appOrderRequest.getGoodsList());
|
||||||
|
//TODO 生成主单 and 细单
|
||||||
|
OrderMaster orderMaster = orderMasterService.createMasterOrder(appOrderRequest);
|
||||||
//TODO 生成细单
|
//TODO 生成细单
|
||||||
|
|
||||||
//TODO 生成财务主单
|
//TODO 生成财务主单
|
||||||
|
|
||||||
//TODO 生成财务细单
|
//TODO 生成财务细单(含分销等.)
|
||||||
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.ghy.web.controller.pay;
|
||||||
|
|
||||||
|
import com.ghy.common.adapay.AdapayService;
|
||||||
|
import com.ghy.common.adapay.callback.PayCallback;
|
||||||
|
import com.ghy.common.core.controller.BaseController;
|
||||||
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
import com.ghy.order.domain.OrderMaster;
|
||||||
|
import com.ghy.order.service.OrderMasterService;
|
||||||
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝支付API
|
||||||
|
*
|
||||||
|
* @author HH 2022/5/10
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("pay/ali")
|
||||||
|
public class AlipayController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayCallback payCallback;
|
||||||
|
@Resource
|
||||||
|
private AdapayService adapayService;
|
||||||
|
@Resource
|
||||||
|
private OrderMasterService orderMasterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝正扫支付
|
||||||
|
*/
|
||||||
|
@PostMapping("qr")
|
||||||
|
public AjaxResult qrPay(String orderMasterCode) {
|
||||||
|
OrderMaster orderMaster = orderMasterService.selectByCode(orderMasterCode);
|
||||||
|
if (orderMaster == null) {
|
||||||
|
return AjaxResult.error("订单不存在");
|
||||||
|
}
|
||||||
|
Map<String, Object> map;
|
||||||
|
try {
|
||||||
|
// TODO 订单里需要补充支付金额、tittle、简要描述、分账信息、description
|
||||||
|
map = adapayService.alipayQrPay(payCallback, orderMaster.getCode(), "orderMaster.get支付金额",
|
||||||
|
"orderMaster.getTittle()", "orderMaster.get简要描述", "orderMaster.getDivMember", "orderMaster.getDescription");
|
||||||
|
} catch (BaseAdaPayException e) {
|
||||||
|
logger.error("获取微信用户信息失败", e);
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
return AjaxResult.success(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,8 +2,8 @@ package com.ghy.web.controller.pay;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ghy.common.adapay.AdapayService;
|
import com.ghy.common.adapay.AdapayService;
|
||||||
|
import com.ghy.common.adapay.callback.PayCallback;
|
||||||
import com.ghy.common.adapay.callback.model.WxLiteExpend;
|
import com.ghy.common.adapay.callback.model.WxLiteExpend;
|
||||||
import com.ghy.common.adapay.callback.reply.WxPubPayCallBack;
|
|
||||||
import com.ghy.common.config.WxConfig;
|
import com.ghy.common.config.WxConfig;
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
|
@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
|
@ -34,16 +33,20 @@ public class WxPayController extends BaseController {
|
||||||
private AdapayService adapayService;
|
private AdapayService adapayService;
|
||||||
@Resource
|
@Resource
|
||||||
private OrderMasterService orderMasterService;
|
private OrderMasterService orderMasterService;
|
||||||
|
@Resource
|
||||||
|
private PayCallback payCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序支付
|
||||||
|
*/
|
||||||
@PostMapping("lite")
|
@PostMapping("lite")
|
||||||
public AjaxResult litePay(HttpServletRequest request) {
|
public AjaxResult litePay(HttpServletRequest request) {
|
||||||
String code = request.getParameter("code");
|
String code = request.getParameter("code");
|
||||||
String orderMasterCode = request.getParameter("orderMasterCode");
|
String orderMasterCode = request.getParameter("orderMasterCode");
|
||||||
List<OrderMaster> orderMasters = orderMasterService.selectOrderMasterList(new OrderMaster(orderMasterCode));
|
OrderMaster orderMaster = orderMasterService.selectByCode(orderMasterCode);
|
||||||
if (orderMasters.isEmpty()) {
|
if (orderMaster == null) {
|
||||||
return AjaxResult.error("订单不存在");
|
return AjaxResult.error("订单不存在");
|
||||||
}
|
}
|
||||||
OrderMaster orderMaster = orderMasters.get(0);
|
|
||||||
JSONObject wxUser;
|
JSONObject wxUser;
|
||||||
try {
|
try {
|
||||||
wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret());
|
wxUser = WxUtils.getOpenid(code, wxConfig.getAppId(), wxConfig.getSecret());
|
||||||
|
|
@ -54,11 +57,11 @@ public class WxPayController extends BaseController {
|
||||||
String openId = wxUser.getString("openid");
|
String openId = wxUser.getString("openid");
|
||||||
//调用adapay微信公众号支付.
|
//调用adapay微信公众号支付.
|
||||||
WxLiteExpend expend = new WxLiteExpend();
|
WxLiteExpend expend = new WxLiteExpend();
|
||||||
expend.setOpen_id(openId);
|
expend.setOpenId(openId);
|
||||||
Map<String, Object> map;
|
Map<String, Object> map;
|
||||||
try {
|
try {
|
||||||
// TODO 订单里需要补充支付金额、tittle、简要描述、分账信息、description
|
// TODO 订单里需要补充支付金额、tittle、简要描述、分账信息、description
|
||||||
map = adapayService.wxPubPay(new WxPubPayCallBack(), expend, orderMaster.getCode(), "orderMaster.get支付金额",
|
map = adapayService.wxPubPay(payCallback, expend, orderMaster.getCode(), "orderMaster.get支付金额",
|
||||||
"orderMaster.getTittle()", "orderMaster.get简要描述", "orderMaster.getDivMember", "orderMaster.getDescription");
|
"orderMaster.getTittle()", "orderMaster.get简要描述", "orderMaster.getDivMember", "orderMaster.getDescription");
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
logger.error("获取微信用户信息失败", e);
|
logger.error("获取微信用户信息失败", e);
|
||||||
|
|
@ -89,8 +92,8 @@ public class WxPayController extends BaseController {
|
||||||
logger.info("open id is " + openId);
|
logger.info("open id is " + openId);
|
||||||
//调用adapay微信公众号支付.
|
//调用adapay微信公众号支付.
|
||||||
WxLiteExpend expend = new WxLiteExpend();
|
WxLiteExpend expend = new WxLiteExpend();
|
||||||
expend.setOpen_id(openId);
|
expend.setOpenId(openId);
|
||||||
Map<String, Object> map = adapayService.wxPubPay(new WxPubPayCallBack(), expend, "wxPay123456" + Math.ceil(Math.random() * 100), "1.00",
|
Map<String, Object> map = adapayService.wxPubPay(payCallback, expend, "wxPay123456" + Math.ceil(Math.random() * 100), "1.00",
|
||||||
"测试商品", "测试商品detail", null, "description");
|
"测试商品", "测试商品detail", null, "description");
|
||||||
//拼接消息给前端.前端通过JSAPI调用微信支付
|
//拼接消息给前端.前端通过JSAPI调用微信支付
|
||||||
map.forEach((key, value) -> {
|
map.forEach((key, value) -> {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.ghy.web.core;
|
||||||
|
|
||||||
|
import com.ghy.common.adapay.callback.PayCallback;
|
||||||
|
import com.ghy.common.adapay.callback.model.PayReply;
|
||||||
|
import com.ghy.order.service.OrderDetailService;
|
||||||
|
import com.ghy.order.service.OrderMasterService;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付后
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class AfterPay {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
OrderMasterService orderMasterService;
|
||||||
|
@Resource
|
||||||
|
OrderDetailService orderDetailService;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PayCallback payCallback() {
|
||||||
|
return new PayCallback() {
|
||||||
|
@Override
|
||||||
|
public void onReply(PayReply reply) {
|
||||||
|
// TODO 修改 OrderMaster 订单状态
|
||||||
|
// TODO 修改 OrderDetail 订单状态
|
||||||
|
// TODO 保存支付结果到MySQL
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,126 +1,124 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<th:block th:include="include :: header('新增商品')" />
|
<th:block th:include="include :: header('新增商品')"/>
|
||||||
<th:block th:include="include :: select2-css" />
|
<th:block th:include="include :: select2-css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<form id="form-goods-add" class="form-horizontal">
|
<form id="form-goods-add" class="form-horizontal">
|
||||||
<h4 class="form-header h4">基本信息</h4>
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">商品名称:</label>
|
<label class="col-sm-4 control-label is-required">商品名称:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input name="goodsName" placeholder="请输入商品名称" class="form-control" type="text" maxlength="30" required>
|
<input name="goodsName" placeholder="请输入商品名称" class="form-control" type="text" maxlength="30"
|
||||||
</div>
|
required>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label is-required">价格:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input name="goodsPrice" placeholder="请输入商品价格" class="form-control" type="text" maxlength="12" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="col-sm-6">
|
||||||
<div class="col-sm-6">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label class="col-sm-4 control-label is-required">价格:</label>
|
||||||
<label class="col-sm-4 control-label is-required">优惠价:</label>
|
<div class="col-sm-8">
|
||||||
<div class="col-sm-8">
|
<input name="goodsPrice" placeholder="请输入商品价格" class="form-control" type="text" maxlength="12"
|
||||||
<input name="discountsPrice" placeholder="请输入优惠价" class="form-control" type="text" maxlength="12" required>
|
required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
</div>
|
||||||
<div class="form-group">
|
<div class="row">
|
||||||
<label class="col-sm-4 control-label is-required">团购价:</label>
|
<div class="col-sm-6">
|
||||||
<div class="col-sm-8">
|
<div class="form-group">
|
||||||
<input name="groupPrice" placeholder="请输入团购价" class="form-control" type="text" maxlength="12" required>
|
<label class="col-sm-4 control-label is-required">优惠价:</label>
|
||||||
</div>
|
<div class="col-sm-8">
|
||||||
|
<input name="discountsPrice" placeholder="请输入优惠价" class="form-control" type="text"
|
||||||
|
maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">团购价:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="groupPrice" placeholder="请输入团购价" class="form-control" type="text" maxlength="12"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">商品类别:</label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<select name="deptGoodsCategoryId" class="form-control m-b">
|
||||||
|
<option th:each="item : ${deptGoodsCategories}" th:text="${item.goodsCategoryName}"
|
||||||
|
th:value="${item.deptGoodsCategoryId}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">状态:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('goods_status')}">
|
||||||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
|
||||||
|
th:value="${dict.dictValue}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">商品库存:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsNumber" placeholder="请输入商品库存" class="form-control" type="text" maxlength="12"
|
||||||
|
required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label">商品类别:</label>
|
|
||||||
<div class="col-xs-8">
|
|
||||||
<select name="deptGoodsCategoryId" class="form-control m-b" >
|
|
||||||
<option th:each="item : ${deptGoodsCategories}" th:text="${item.goodsCategoryName}" th:value="${item.deptGoodsCategoryId}"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label">状态:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('goods_status')}">
|
|
||||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label is-required">商品库存:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input name="goodsNumber" placeholder="请输入商品库存" class="form-control" type="text" maxlength="12" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="form-header h4">其他信息</h4>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-xs-2 control-label">备注:</label>
|
|
||||||
<div class="col-xs-10">
|
|
||||||
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-offset-5 col-sm-10">
|
|
||||||
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<th:block th:include="include :: footer" />
|
|
||||||
<th:block th:include="include :: select2-js" />
|
|
||||||
<script>
|
|
||||||
var prefix = ctx + "goods/goods";
|
|
||||||
|
|
||||||
$("#form-goods-add").validate({
|
|
||||||
onkeyup: false,
|
|
||||||
rules:{
|
|
||||||
|
|
||||||
},
|
<h4 class="form-header h4">其他信息</h4>
|
||||||
messages: {
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">备注:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
},
|
<th:block th:include="include :: footer"/>
|
||||||
focusCleanup: true
|
<th:block th:include="include :: select2-js"/>
|
||||||
});
|
|
||||||
|
|
||||||
function submitHandler() {
|
|
||||||
if ($.validate.form()) {
|
|
||||||
var data = $("#form-goods-add").serializeArray();
|
|
||||||
$.operate.saveTab(prefix + "/add", data);
|
|
||||||
$.modal.close(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
<script>
|
||||||
|
var prefix = ctx + "goods/goods";
|
||||||
|
|
||||||
|
$("#form-goods-add").validate({
|
||||||
|
onkeyup: false,
|
||||||
|
rules: {},
|
||||||
|
messages: {},
|
||||||
|
focusCleanup: true
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
var data = $("#form-goods-add").serializeArray();
|
||||||
|
$.operate.saveTab(prefix + "/add", data);
|
||||||
|
$.modal.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('修改商品')"/>
|
||||||
|
<th:block th:include="include :: select2-css"/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="main-content">
|
||||||
|
<form class="form-horizontal" id="form-goods-edit" th:object="${goods}">
|
||||||
|
<input id="goodsId" name="goodsId" type="hidden" th:field="*{goodsId}"/>
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">商品名称:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsName" placeholder="请输入商品名称" class="form-control" type="text" maxlength="30"
|
||||||
|
th:field="*{goodsName}"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">价格:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsPrice" placeholder="请输入商品价格" class="form-control" type="text" maxlength="12"
|
||||||
|
th:field="*{goodsPrice}"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">优惠价:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="discountsPrice" placeholder="请输入优惠价" class="form-control" type="text"
|
||||||
|
th:field="*{discountsPrice}"
|
||||||
|
maxlength="12" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">团购价:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="groupPrice" placeholder="请输入团购价" class="form-control" type="text" maxlength="12"
|
||||||
|
th:field="*{groupPrice}"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">商品类别:</label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<select name="deptGoodsCategoryId" class="form-control m-b">
|
||||||
|
<option th:each="item : ${deptGoodsCategories}" th:text="${item.goodsCategoryName}"
|
||||||
|
th:value="${item.deptGoodsCategoryId}" th:field="*{deptGoodsCategoryId}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label">状态:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('goods_status')}">
|
||||||
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:field="*{status}"
|
||||||
|
th:value="${dict.dictValue}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">商品库存:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="goodsNumber" placeholder="请输入商品库存" class="form-control" type="text" maxlength="12"
|
||||||
|
th:field="*{goodsNumber}"
|
||||||
|
required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4 class="form-header h4">其他信息</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">备注:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<textarea name="remark" maxlength="500" class="form-control" rows="3"
|
||||||
|
th:field="*{remark}"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<th:block th:include="include :: footer"/>
|
||||||
|
<th:block th:include="include :: select2-js"/>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var prefix = ctx + "goods/goods";
|
||||||
|
|
||||||
|
$("#form-goods-edit").validate({
|
||||||
|
onkeyup: false,
|
||||||
|
rules: {},
|
||||||
|
messages: {},
|
||||||
|
focusCleanup: true
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
if ($.validate.form()) {
|
||||||
|
var data = $("#form-goods-edit").serializeArray();
|
||||||
|
$.operate.saveTab(prefix + "/edit", data);
|
||||||
|
$.modal.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -159,7 +159,7 @@ public class AdapayService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序支付
|
* 微信公众号支付
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> wxPubPay(PayCallback callback, WxLiteExpend expend, String orderNo, String payAmt,
|
public Map<String, Object> wxPubPay(PayCallback callback, WxLiteExpend expend, String orderNo, String payAmt,
|
||||||
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
|
String goodsTittle, String goodsDesc, String divMembers, String description) throws BaseAdaPayException {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
package com.ghy.common.adapay.callback.model;
|
package com.ghy.common.adapay.callback.model;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 所有支付渠道扩展参数的父类
|
||||||
|
*
|
||||||
* @author HH 2022/3/31
|
* @author HH 2022/3/31
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
public class Expend {
|
public class Expend {
|
||||||
|
|
||||||
private String open_id;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ghy.common.adapay.callback.reply;
|
|
||||||
|
|
||||||
import com.ghy.common.adapay.callback.PayCallback;
|
|
||||||
import com.ghy.common.adapay.callback.model.PayReply;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class WxPubPayCallBack implements PayCallback {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReply(PayReply reply) {
|
|
||||||
// 更新工单状态
|
|
||||||
log.info("wx pub pay response is : " + reply.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel;
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author clunt
|
* @author clunt
|
||||||
* 消费者实体
|
* 消费者实体
|
||||||
|
|
@ -37,5 +39,10 @@ public class Customer extends BaseEntity {
|
||||||
@Excel(name = "用户头像", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "用户头像", cellType = Excel.ColumnType.STRING)
|
||||||
private String customerLogoUrl;
|
private String customerLogoUrl;
|
||||||
|
|
||||||
|
@Excel(name = "上级分销人", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long customerPlace;
|
||||||
|
|
||||||
|
@Excel(name = "祖级分销人", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long parentCustomerPlace;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
package com.ghy.customer.domain;
|
|
||||||
|
|
||||||
import com.ghy.common.annotation.Excel;
|
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author clunt
|
|
||||||
* 用户多级分销,最多不超过3级
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CustomerPlace extends BaseEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Excel(name = "分销id", cellType = Excel.ColumnType.NUMERIC)
|
|
||||||
private Long customerPlaceId;
|
|
||||||
|
|
||||||
@Excel(name = "用户id", cellType = Excel.ColumnType.NUMERIC)
|
|
||||||
private Long customerId;
|
|
||||||
|
|
||||||
@Excel(name = "父级id", cellType = Excel.ColumnType.NUMERIC)
|
|
||||||
private Long parentCustomerId;
|
|
||||||
|
|
||||||
@Excel(name = "分销类型", cellType = Excel.ColumnType.STRING)
|
|
||||||
private Integer placeType;
|
|
||||||
|
|
||||||
@Excel(name = "分销比例", cellType = Excel.ColumnType.STRING)
|
|
||||||
private String placeRate;
|
|
||||||
|
|
||||||
@Excel(name = "分销金额", cellType = Excel.ColumnType.STRING)
|
|
||||||
private String placeMoney;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
package com.ghy.customer.mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author clunt
|
|
||||||
* 多级分销接口类
|
|
||||||
*/
|
|
||||||
public interface CustomerPlaceMapper {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ghy.customer.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author clunt
|
|
||||||
* 多级分销
|
|
||||||
*/
|
|
||||||
public interface CustomerPlaceService {
|
|
||||||
|
|
||||||
// 新增分销用户
|
|
||||||
|
|
||||||
// 获取用户分销关系
|
|
||||||
|
|
||||||
// 设置分销比例
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ghy.customer.service.impl;
|
|
||||||
|
|
||||||
import com.ghy.customer.service.CustomerPlaceService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author clunt
|
|
||||||
* 多级分销实现类
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CustomerPlaceServiceImpl implements CustomerPlaceService {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.ghy.common.exception.ServiceException;
|
||||||
import com.ghy.customer.domain.Customer;
|
import com.ghy.customer.domain.Customer;
|
||||||
import com.ghy.customer.mapper.CustomerMapper;
|
import com.ghy.customer.mapper.CustomerMapper;
|
||||||
import com.ghy.customer.service.CustomerService;
|
import com.ghy.customer.service.CustomerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -18,7 +17,7 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class CustomerServiceImpl implements CustomerService {
|
public class CustomerServiceImpl implements CustomerService {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private CustomerMapper customerMapper;
|
private CustomerMapper customerMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@
|
||||||
<result property="password" column="password" />
|
<result property="password" column="password" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
<result property="customerLogoUrl" column="customer_logo_url" />
|
<result property="customerLogoUrl" column="customer_logo_url" />
|
||||||
|
<result property="customerPlace" column="customer_place" />
|
||||||
|
<result property="parentCustomerPlace" column="parent_customer_place" />
|
||||||
|
<result property="customerLogoUrl" column="customer_logo_url" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
|
@ -20,7 +23,7 @@
|
||||||
|
|
||||||
<sql id="selectCustomer">
|
<sql id="selectCustomer">
|
||||||
SELECT customer_id, name, account, phone, open_id, password, status,
|
SELECT customer_id, name, account, phone, open_id, password, status,
|
||||||
customer_logo_url, create_by, create_time, remark
|
customer_logo_url, customer_place, parent_customer_place, create_by, create_time, remark
|
||||||
FROM customer
|
FROM customer
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ghy.customer.mapper.CustomerPlaceMapper">
|
|
||||||
|
|
||||||
<resultMap id="GoodsImgsResult" type="com.ghy.customer.domain.CustomerPlace">
|
|
||||||
<result property="customerPlaceId" column="customer_place_id"/>
|
|
||||||
<result property="customerId" column="customer_id" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<sql id="selectCustomerPlace">
|
|
||||||
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ghy.goods.mapper;
|
package com.ghy.goods.mapper;
|
||||||
|
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -11,29 +13,35 @@ import java.util.List;
|
||||||
public interface GoodsMapper {
|
public interface GoodsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品属性
|
* @param goods 商品信息
|
||||||
* @return 成功条数
|
* @return 校验是否满足库存
|
||||||
*/
|
*/
|
||||||
public int insertGoods(Goods goods);
|
int checkAGoodsStore(AppGoodsRequest goods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品属性
|
* @param goods 商品属性
|
||||||
* @return 成功条数
|
* @return 成功条数
|
||||||
*/
|
*/
|
||||||
public int updateGoods(Goods goods);
|
int insertGoods(Goods goods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goods 商品属性
|
||||||
|
* @return 成功条数
|
||||||
|
*/
|
||||||
|
int updateGoods(Goods goods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品入参
|
* @param goods 商品入参
|
||||||
* @return 商品集合
|
* @return 商品集合
|
||||||
*/
|
*/
|
||||||
public List<Goods> selectGoodsList(Goods goods);
|
List<Goods> selectGoodsList(Goods goods);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsId 商品id
|
* @param goodsId 商品id
|
||||||
* @return 商品
|
* @return 商品
|
||||||
*/
|
*/
|
||||||
public Goods selectById(Long goodsId);
|
Goods selectById(Long goodsId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除商品信息
|
* 批量删除商品信息
|
||||||
|
|
@ -41,19 +49,19 @@ public interface GoodsMapper {
|
||||||
* @param goodsId 需要删除的数据ID
|
* @param goodsId 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGoodsByIds(Long[] goodsId);
|
int deleteGoodsByIds(Long[] goodsId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsName 商品名称
|
* @param goodsName 商品名称
|
||||||
* @return 商品信息
|
* @return 商品信息
|
||||||
*/
|
*/
|
||||||
public Goods checkGoodsNameUnique(String goodsName);
|
Goods checkGoodsNameUnique(String goodsName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsCode 商品编码
|
* @param goodsCode 商品编码
|
||||||
* @return 商品信息
|
* @return 商品信息
|
||||||
*/
|
*/
|
||||||
public Goods checkGoodsCodeUnique(String goodsCode);
|
Goods checkGoodsCodeUnique(String goodsCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用商品类别ID查询一条商品信息
|
* 用商品类别ID查询一条商品信息
|
||||||
|
|
@ -63,4 +71,13 @@ public interface GoodsMapper {
|
||||||
* @return 商品信息
|
* @return 商品信息
|
||||||
*/
|
*/
|
||||||
Goods selectOneByGoodsCategoryId(Long goodsCategoryId);
|
Goods selectOneByGoodsCategoryId(Long goodsCategoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置商品编号
|
||||||
|
*
|
||||||
|
* @param goodsId 商品ID
|
||||||
|
* @param goodsCode 商品编号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int setCode(@Param("goodsId") Long goodsId, @Param("goodsCode") String goodsCode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ghy.goods.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序下单请求体
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AppGoodsRequest {
|
||||||
|
|
||||||
|
// 商品id
|
||||||
|
private Long goodsId;
|
||||||
|
|
||||||
|
// 数量
|
||||||
|
private Integer num;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,58 +1,75 @@
|
||||||
package com.ghy.goods.service;
|
package com.ghy.goods.service;
|
||||||
|
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品模块接口
|
* 商品模块接口
|
||||||
|
*
|
||||||
* @author clunt
|
* @author clunt
|
||||||
*/
|
*/
|
||||||
public interface GoodsService {
|
public interface GoodsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品属性
|
* @param goodsList 需要校验库存的商品list
|
||||||
* @return 成功条数
|
* @return 校验结果
|
||||||
*/
|
*/
|
||||||
public int insertGoods(Goods goods);
|
boolean checkStore(List<AppGoodsRequest> goodsList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsList 需要校验库存的商品list
|
||||||
|
* @return 商品总价
|
||||||
|
*/
|
||||||
|
BigDecimal calculate(List<AppGoodsRequest> goodsList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品属性
|
* @param goods 商品属性
|
||||||
* @return 成功条数
|
* @return 成功条数
|
||||||
*/
|
*/
|
||||||
public int updateGoods(Goods goods);
|
int insertGoods(Goods goods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goods 商品属性
|
||||||
|
* @return 成功条数
|
||||||
|
*/
|
||||||
|
int updateGoods(Goods goods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goods 商品入参
|
* @param goods 商品入参
|
||||||
* @return 商品集合
|
* @return 商品集合
|
||||||
*/
|
*/
|
||||||
public List<Goods> selectGoodsList(Goods goods);
|
List<Goods> selectGoodsList(Goods goods);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsId 商品id
|
* @param goodsId 商品id
|
||||||
* @return 商品
|
* @return 商品
|
||||||
*/
|
*/
|
||||||
public Goods selectById(Long goodsId);
|
Goods selectById(Long goodsId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ids 商品ids
|
* @param ids 商品ids
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
public int deleteGoodsByIds(String ids);
|
int deleteGoodsByIds(String ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验商品名称是否重复
|
* 校验商品名称是否重复
|
||||||
|
*
|
||||||
* @param goods 商品属性
|
* @param goods 商品属性
|
||||||
* @return 校验结果 1存在 0不存在
|
* @return 校验结果 1存在 0不存在
|
||||||
*/
|
*/
|
||||||
public String checkGoodsNameUnique(Goods goods);
|
String checkGoodsNameUnique(Goods goods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验商品编码是否重复
|
* 校验商品编码是否重复
|
||||||
|
*
|
||||||
* @param goods 商品属性
|
* @param goods 商品属性
|
||||||
* @return 校验结果 1存在 0不存在
|
* @return 校验结果 1存在 0不存在
|
||||||
*/
|
*/
|
||||||
public String checkGoodsCodeUnique(Goods goods);
|
String checkGoodsCodeUnique(Goods goods);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,19 @@ import com.ghy.common.exception.ServiceException;
|
||||||
import com.ghy.common.utils.StringUtils;
|
import com.ghy.common.utils.StringUtils;
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
import com.ghy.goods.mapper.GoodsMapper;
|
import com.ghy.goods.mapper.GoodsMapper;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
import com.ghy.goods.service.GoodsService;
|
import com.ghy.goods.service.GoodsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品模块实现类
|
* 商品模块实现类
|
||||||
|
*
|
||||||
* @author clunt
|
* @author clunt
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -23,8 +28,33 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
private GoodsMapper goodsMapper;
|
private GoodsMapper goodsMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public boolean checkStore(List<AppGoodsRequest> goodsList) {
|
||||||
|
for (AppGoodsRequest goods : goodsList) {
|
||||||
|
int num = goodsMapper.checkAGoodsStore(goods);
|
||||||
|
if (num == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal calculate(List<AppGoodsRequest> goodsList) {
|
||||||
|
BigDecimal totalPay = BigDecimal.ZERO;
|
||||||
|
for (AppGoodsRequest appGoodsRequest : goodsList){
|
||||||
|
Goods goods = goodsMapper.selectById(appGoodsRequest.getGoodsId());
|
||||||
|
totalPay = totalPay.add(goods.getGoodsPrice().multiply(BigDecimal.valueOf(appGoodsRequest.getNum())));
|
||||||
|
}
|
||||||
|
return totalPay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertGoods(Goods goods) {
|
public int insertGoods(Goods goods) {
|
||||||
return goodsMapper.insertGoods(goods);
|
goodsMapper.insertGoods(goods);
|
||||||
|
Assert.notNull(goods.getGoodsId(), "操作失败");
|
||||||
|
String code = String.format("GD%019d", goods.getGoodsId());
|
||||||
|
return goodsMapper.setCode(goods.getGoodsId(), code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -45,11 +75,9 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
@Override
|
@Override
|
||||||
public int deleteGoodsByIds(String ids) {
|
public int deleteGoodsByIds(String ids) {
|
||||||
Long[] goodsIds = Convert.toLongArray(ids);
|
Long[] goodsIds = Convert.toLongArray(ids);
|
||||||
for (Long goodsId : goodsIds)
|
for (Long goodsId : goodsIds) {
|
||||||
{
|
|
||||||
Goods goods = selectById(goodsId);
|
Goods goods = selectById(goodsId);
|
||||||
if (countUserGoodsById(goods) > 0)
|
if (countUserGoodsById(goods) > 0) {
|
||||||
{
|
|
||||||
throw new ServiceException(String.format("%1$s正在使用,不能删除", goods.getGoodsName()));
|
throw new ServiceException(String.format("%1$s正在使用,不能删除", goods.getGoodsName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,8 +88,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
public String checkGoodsNameUnique(Goods goods) {
|
public String checkGoodsNameUnique(Goods goods) {
|
||||||
Long goodsId = StringUtils.isNull(goods.getGoodsId()) ? -1L : goods.getGoodsId();
|
Long goodsId = StringUtils.isNull(goods.getGoodsId()) ? -1L : goods.getGoodsId();
|
||||||
Goods info = goodsMapper.checkGoodsNameUnique(goods.getGoodsName());
|
Goods info = goodsMapper.checkGoodsNameUnique(goods.getGoodsName());
|
||||||
if (StringUtils.isNotNull(info) && info.getGoodsId().longValue() != goodsId.longValue())
|
if (StringUtils.isNotNull(info) && info.getGoodsId().longValue() != goodsId.longValue()) {
|
||||||
{
|
|
||||||
return UserConstants.GOODS_NAME_NOT_UNIQUE;
|
return UserConstants.GOODS_NAME_NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.GOODS_NAME_UNIQUE;
|
return UserConstants.GOODS_NAME_UNIQUE;
|
||||||
|
|
@ -71,15 +98,14 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
public String checkGoodsCodeUnique(Goods goods) {
|
public String checkGoodsCodeUnique(Goods goods) {
|
||||||
Long goodsId = StringUtils.isNull(goods.getGoodsId()) ? -1L : goods.getGoodsId();
|
Long goodsId = StringUtils.isNull(goods.getGoodsId()) ? -1L : goods.getGoodsId();
|
||||||
Goods info = goodsMapper.checkGoodsCodeUnique(goods.getGoodsCode());
|
Goods info = goodsMapper.checkGoodsCodeUnique(goods.getGoodsCode());
|
||||||
if (StringUtils.isNotNull(info) && info.getGoodsId().longValue() != goodsId.longValue())
|
if (StringUtils.isNotNull(info) && info.getGoodsId().longValue() != goodsId.longValue()) {
|
||||||
{
|
|
||||||
return UserConstants.GOODS_CODE_NOT_UNIQUE;
|
return UserConstants.GOODS_CODE_NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.GOODS_CODE_UNIQUE;
|
return UserConstants.GOODS_CODE_UNIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int countUserGoodsById(Goods goods){
|
public int countUserGoodsById(Goods goods) {
|
||||||
//TODO 校验商品是否上架
|
//TODO 校验商品是否上架
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,15 @@
|
||||||
FROM goods
|
FROM goods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<select id="checkAGoodsStore" parameterType="com.ghy.goods.request.AppGoodsRequest" resultMap="GoodsResult">
|
||||||
|
<include refid="selectGoods" />
|
||||||
|
where goods_id = #{goodsId} and goods_number >= #{num}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
||||||
UPDATE goods
|
UPDATE goods
|
||||||
<set>
|
<set>
|
||||||
<if test="goodsCode != null and goodsCode != ''">goods_code = #{goodsCode},</if>
|
|
||||||
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
|
|
||||||
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
||||||
<if test="goodsPrice != null and goodsPrice != ''">goods_price = #{goodsPrice},</if>
|
<if test="goodsPrice != null and goodsPrice != ''">goods_price = #{goodsPrice},</if>
|
||||||
<if test="discountsPrice != null and discountsPrice != ''">discounts_price = #{discountsPrice},</if>
|
<if test="discountsPrice != null and discountsPrice != ''">discounts_price = #{discountsPrice},</if>
|
||||||
|
|
@ -52,6 +56,12 @@
|
||||||
WHERE goods_id = #{goodsId}
|
WHERE goods_id = #{goodsId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="setCode">
|
||||||
|
UPDATE goods
|
||||||
|
SET goods_code = #{goodsCode}, update_time = sysdate()
|
||||||
|
WHERE goods_id = #{goodsId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<insert id="insertGoods" parameterType="com.ghy.goods.domain.Goods" useGeneratedKeys="true" keyProperty="goodsId">
|
<insert id="insertGoods" parameterType="com.ghy.goods.domain.Goods" useGeneratedKeys="true" keyProperty="goodsId">
|
||||||
insert into goods(
|
insert into goods(
|
||||||
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@
|
||||||
<artifactId>ghy-common</artifactId>
|
<artifactId>ghy-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ghy</groupId>
|
||||||
|
<artifactId>ghy-goods</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,11 @@ public interface OrderMasterMapper {
|
||||||
*/
|
*/
|
||||||
OrderMaster checkOrderMasterCodeUnique(String orderMasterCode);
|
OrderMaster checkOrderMasterCodeUnique(String orderMasterCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用 OrderMaster 查询主订单信息
|
||||||
|
*
|
||||||
|
* @param orderMasterCode 主订单code
|
||||||
|
* @return 主订单信息
|
||||||
|
*/
|
||||||
|
OrderMaster selectByCode(String orderMasterCode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.ghy.order.request;
|
||||||
|
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序下单请求体
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AppOrderRequest {
|
||||||
|
|
||||||
|
// 消费者id
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
// 用于计算价格等
|
||||||
|
private List<AppGoodsRequest> goodsList;
|
||||||
|
|
||||||
|
// 预约上门时间
|
||||||
|
private String serverTime;
|
||||||
|
|
||||||
|
// 地址
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
// 支付方式
|
||||||
|
private Integer payType;
|
||||||
|
|
||||||
|
//是否需要发票
|
||||||
|
private Integer isNeedBill;
|
||||||
|
|
||||||
|
// 备注
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ghy.order.service;
|
package com.ghy.order.service;
|
||||||
|
|
||||||
import com.ghy.order.domain.OrderMaster;
|
import com.ghy.order.domain.OrderMaster;
|
||||||
|
import com.ghy.order.request.AppOrderRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -11,6 +12,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface OrderMasterService {
|
public interface OrderMasterService {
|
||||||
|
|
||||||
|
OrderMaster createMasterOrder(AppOrderRequest appOrderRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param orderMaster 主订单属性
|
* @param orderMaster 主订单属性
|
||||||
* @return 成功条数
|
* @return 成功条数
|
||||||
|
|
@ -36,6 +39,14 @@ public interface OrderMasterService {
|
||||||
*/
|
*/
|
||||||
OrderMaster selectById(Long orderMasterId);
|
OrderMaster selectById(Long orderMasterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用 OrderMaster 查询主订单信息
|
||||||
|
*
|
||||||
|
* @param orderMasterCode 主订单code
|
||||||
|
* @return 主订单信息
|
||||||
|
*/
|
||||||
|
OrderMaster selectByCode(String orderMasterCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ids 主订单ids
|
* @param ids 主订单ids
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.ghy.common.constant.UserConstants;
|
||||||
import com.ghy.common.core.text.Convert;
|
import com.ghy.common.core.text.Convert;
|
||||||
import com.ghy.order.domain.OrderMaster;
|
import com.ghy.order.domain.OrderMaster;
|
||||||
import com.ghy.order.mapper.OrderMasterMapper;
|
import com.ghy.order.mapper.OrderMasterMapper;
|
||||||
|
import com.ghy.order.request.AppOrderRequest;
|
||||||
import com.ghy.order.service.OrderMasterService;
|
import com.ghy.order.service.OrderMasterService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -21,6 +22,11 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
||||||
@Resource
|
@Resource
|
||||||
private OrderMasterMapper orderMasterMapper;
|
private OrderMasterMapper orderMasterMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMaster createMasterOrder(AppOrderRequest appOrderRequest) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertOrderMaster(OrderMaster orderMaster) {
|
public int insertOrderMaster(OrderMaster orderMaster) {
|
||||||
return orderMasterMapper.insertOrderMaster(orderMaster);
|
return orderMasterMapper.insertOrderMaster(orderMaster);
|
||||||
|
|
@ -41,6 +47,11 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
||||||
return orderMasterMapper.selectById(orderMasterId);
|
return orderMasterMapper.selectById(orderMasterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderMaster selectByCode(String orderMasterCode) {
|
||||||
|
return orderMasterMapper.selectByCode(orderMasterCode);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteOrderMasterByIds(String ids) {
|
public int deleteOrderMasterByIds(String ids) {
|
||||||
Long[] orderMasterIds = Convert.toLongArray(ids);
|
Long[] orderMasterIds = Convert.toLongArray(ids);
|
||||||
|
|
|
||||||
|
|
@ -133,4 +133,9 @@
|
||||||
WHERE `code` =#{orderMasterCode} LIMIT 1
|
WHERE `code` =#{orderMasterCode} LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByCode" parameterType="String" resultType="com.ghy.order.domain.OrderMaster">
|
||||||
|
<include refid="selectOrderMaster"/>
|
||||||
|
WHERE `code` = #{orderMasterCode}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue