Merge remote-tracking branch 'origin/master'
# Conflicts: # ghy-admin/src/main/java/com/ghy/web/controller/pay/WxPayController.java # ghy-common/src/main/java/com/ghy/common/adapay/AdapayService.java
This commit is contained in:
commit
dacc4862e6
|
|
@ -37,7 +37,7 @@ public class GoodsController extends BaseController {
|
|||
return PREFIX + "/goods";
|
||||
}
|
||||
|
||||
@RequiresPermissions("goods:goods:list")
|
||||
// @RequiresPermissions("goods:goods:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(Goods goods) {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@ import com.ghy.payment.service.FinancialMasterService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author clunt
|
||||
|
|
@ -48,7 +50,8 @@ public class OrderController extends BaseController {
|
|||
|
||||
|
||||
@PostMapping("/server/app")
|
||||
public AjaxResult appOrder(AppOrderRequest appOrderRequest){
|
||||
@ResponseBody
|
||||
public AjaxResult appOrder(@RequestBody AppOrderRequest appOrderRequest){
|
||||
// 校验用户信息
|
||||
Customer customer = customerService.selectByCustomerId(appOrderRequest.getCustomerId());
|
||||
if(StringUtils.isNull(customer)){
|
||||
|
|
@ -61,15 +64,22 @@ public class OrderController extends BaseController {
|
|||
}
|
||||
// 计算商品费用
|
||||
BigDecimal totalPay = goodsService.calculate(appOrderRequest.getGoodsList());
|
||||
//TODO 生成主单 and 细单
|
||||
OrderMaster orderMaster = orderMasterService.createMasterOrder(appOrderRequest);
|
||||
//TODO 生成细单
|
||||
|
||||
// 生成主单
|
||||
OrderMaster orderMaster = new OrderMaster();
|
||||
orderMaster.setCode(orderMasterService.createOrderCode());
|
||||
orderMaster.setOrderType(1);
|
||||
orderMaster.setOrderStatus(0);
|
||||
orderMaster.setCustomerId(appOrderRequest.getCustomerId());
|
||||
orderMaster.setPayStatus(0);
|
||||
orderMaster.setCreateTime(new Date());
|
||||
orderMasterService.insertOrderMaster(orderMaster);
|
||||
//TODO 生成财务主单
|
||||
|
||||
//TODO 生成细单
|
||||
|
||||
//TODO 生成财务细单(含分销等.)
|
||||
|
||||
return AjaxResult.success();
|
||||
return AjaxResult.success(orderMaster);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ public class WxPayController extends BaseController {
|
|||
* 微信小程序支付
|
||||
*/
|
||||
@PostMapping("lite")
|
||||
@ResponseBody
|
||||
public AjaxResult litePay(HttpServletRequest request) {
|
||||
String code = request.getParameter("code");
|
||||
String orderMasterCode = request.getParameter("orderMasterCode");
|
||||
String code = request.getHeader("code");
|
||||
String orderMasterCode = request.getHeader("orderMasterCode");
|
||||
OrderMaster orderMaster = orderMasterService.selectByCode(orderMasterCode);
|
||||
if (orderMaster == null) {
|
||||
return AjaxResult.error("订单不存在");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ public class WxController extends BaseController {
|
|||
|
||||
@GetMapping("/auth")
|
||||
@ResponseBody
|
||||
public AjaxResult auth(String code) {
|
||||
public AjaxResult auth(HttpServletRequest request) {
|
||||
String code = request.getHeader("code");
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||
String data = HttpUtils.sendGet(url, null);
|
||||
JSONObject result = JSONObject.parseObject(data);
|
||||
|
|
|
|||
|
|
@ -143,8 +143,10 @@ swagger:
|
|||
|
||||
#小程序配置
|
||||
wx:
|
||||
appId: 'wx404f2439a8c24e15'
|
||||
secret: '49ade04a817067fe2d65ab2f17afce75'
|
||||
appId: 'wxc39c2af3ea24cd37'
|
||||
secret: '96d566c3169b8715904950d9cf3cbf60'
|
||||
# appId: 'wx404f2439a8c24e15'
|
||||
# secret: '49ade04a817067fe2d65ab2f17afce75'
|
||||
|
||||
#七牛云配置
|
||||
qiniu:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ServletUtils
|
|||
*/
|
||||
public static String getParameter(String name)
|
||||
{
|
||||
return getRequest().getParameter(name);
|
||||
return StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +34,8 @@ public class ServletUtils
|
|||
*/
|
||||
public static String getParameter(String name, String defaultValue)
|
||||
{
|
||||
return Convert.toStr(getRequest().getParameter(name), defaultValue);
|
||||
String value = StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
return Convert.toStr(value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +43,8 @@ public class ServletUtils
|
|||
*/
|
||||
public static Integer getParameterToInt(String name)
|
||||
{
|
||||
return Convert.toInt(getRequest().getParameter(name));
|
||||
String value = StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
return Convert.toInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +52,8 @@ public class ServletUtils
|
|||
*/
|
||||
public static Integer getParameterToInt(String name, Integer defaultValue)
|
||||
{
|
||||
return Convert.toInt(getRequest().getParameter(name), defaultValue);
|
||||
String value = StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
return Convert.toInt(value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -58,7 +61,8 @@ public class ServletUtils
|
|||
*/
|
||||
public static Boolean getParameterToBool(String name)
|
||||
{
|
||||
return Convert.toBool(getRequest().getParameter(name));
|
||||
String value = StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
return Convert.toBool(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +70,8 @@ public class ServletUtils
|
|||
*/
|
||||
public static Boolean getParameterToBool(String name, Boolean defaultValue)
|
||||
{
|
||||
return Convert.toBool(getRequest().getParameter(name), defaultValue);
|
||||
String value = StringUtils.isNotEmpty(getRequest().getHeader(name)) ? getRequest().getHeader(name):getRequest().getParameter(name);
|
||||
return Convert.toBool(value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ public class ShiroConfig
|
|||
//部分接口不需要登陆校验
|
||||
filterChainDefinitionMap.put("/wx/**", "anon");
|
||||
filterChainDefinitionMap.put("/pay/**", "anon");
|
||||
filterChainDefinitionMap.put("/order/**", "anon");
|
||||
filterChainDefinitionMap.put("/goods/**", "anon");
|
||||
filterChainDefinitionMap.put("/adapay/**", "anon");
|
||||
filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public interface GoodsMapper {
|
|||
* @param goods 商品信息
|
||||
* @return 校验是否满足库存
|
||||
*/
|
||||
int checkAGoodsStore(AppGoodsRequest goods);
|
||||
List<Goods> checkAGoodsStore(AppGoodsRequest goods);
|
||||
|
||||
/**
|
||||
* @param goods 商品属性
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ public class GoodsServiceImpl implements GoodsService {
|
|||
@Override
|
||||
public boolean checkStore(List<AppGoodsRequest> goodsList) {
|
||||
for (AppGoodsRequest goods : goodsList) {
|
||||
int num = goodsMapper.checkAGoodsStore(goods);
|
||||
if (num == 0) {
|
||||
List<Goods> list = goodsMapper.checkAGoodsStore(goods);
|
||||
if (list.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,10 +43,4 @@ public class OrderMaster extends BaseEntity {
|
|||
@Excel(name = "接单时间", cellType = Excel.ColumnType.STRING)
|
||||
private String revTime;
|
||||
|
||||
public OrderMaster() {
|
||||
}
|
||||
|
||||
public OrderMaster(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import java.util.List;
|
|||
*/
|
||||
public interface OrderMasterService {
|
||||
|
||||
String createOrderCode();
|
||||
|
||||
OrderMaster createMasterOrder(AppOrderRequest appOrderRequest);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ import com.ghy.order.service.OrderMasterService;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* 商品模块实现类
|
||||
|
|
@ -22,6 +25,16 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
|||
@Resource
|
||||
private OrderMasterMapper orderMasterMapper;
|
||||
|
||||
AtomicLong index = new AtomicLong(1L);
|
||||
|
||||
private final static ThreadLocal<SimpleDateFormat> dateFormat = ThreadLocal.withInitial(()->new SimpleDateFormat("yyyyMMddHHmmss"));
|
||||
|
||||
@Override
|
||||
public String createOrderCode() {
|
||||
index.compareAndSet(9999L, 1L);
|
||||
return "om" + dateFormat.get().format(new Date()) + index.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderMaster createMasterOrder(AppOrderRequest appOrderRequest) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
<insert id="insertOrderMaster" parameterType="com.ghy.order.domain.OrderMaster" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO order_master(
|
||||
<if test="code != null and code != 0">code,</if>
|
||||
<if test="code != null ">code,</if>
|
||||
<if test="customerId != null and customerId != ''">customer_id,</if>
|
||||
<if test="orderType != null and orderType != ''">order_type,</if>
|
||||
<if test="orderStatus != null and orderStatus != ''">order_status,</if>
|
||||
|
|
@ -114,7 +114,7 @@
|
|||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)VALUES(
|
||||
<if test="code != null and code != 0">#{code},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
<if test="customerId != null and customerId != ''">#{customerId},</if>
|
||||
<if test="orderType != null and orderType != ''">#{orderType},</if>
|
||||
<if test="orderStatus != null and orderStatus != ''">#{orderStatus},</if>
|
||||
Loading…
Reference in New Issue