|
@@ -65,22 +65,22 @@ import com.iamberry.wechat.tools.ValidatorUtil;
|
|
|
@Controller
|
|
|
@RequestMapping("/wechat/order")
|
|
|
public class OrderHandler {
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private CartService cartService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private HomeService homeService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private SystemService systemService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ValidatorUtil validatorUtil;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private PayService payService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private MemberService memberService;
|
|
|
@Autowired
|
|
@@ -106,10 +106,10 @@ public class OrderHandler {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/payBefore", method = RequestMethod.POST)
|
|
|
public ResultMsg payBefore(HttpServletRequest request) throws Exception {
|
|
|
-
|
|
|
+
|
|
|
ResultMsg msg = new ResultMsg();
|
|
|
msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
-
|
|
|
+
|
|
|
OrderPayDto dto = new OrderPayDto();
|
|
|
// 用户信息
|
|
|
Member member = WechatUtils.getUserBySession(request);
|
|
@@ -148,7 +148,7 @@ public class OrderHandler {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
- //如果是有二维码的商户,进入后显示优惠价
|
|
|
+ /*//如果是有二维码的商户,进入后显示优惠价
|
|
|
int num = productInfoService.getQrCodeByPlaceOpenId(member.getUserOpenid());
|
|
|
if (num > 0) {
|
|
|
QrcodeGift gift = new QrcodeGift();
|
|
@@ -164,13 +164,13 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }*/
|
|
|
+
|
|
|
//判断是否为金牌会员下线,如果是,则以优惠价显示,如果不是则按原价显示
|
|
|
//查询金牌会员模板id
|
|
|
int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
|
|
|
//如果模板id等于金牌会模板id,则该用户为金牌会员下线
|
|
|
- if (member.getUserDealers() != null && member.getTemplateId() != null
|
|
|
+ if (member.getUserDealers() != null && member.getTemplateId() != null
|
|
|
&& templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
|
|
|
//若果是金牌会员下线,产品的价格就以优惠价显示
|
|
|
if (cartDtos != null && cartDtos.size() >= 1) {
|
|
@@ -187,7 +187,7 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//根据openid查询该用户是否购买过订单
|
|
|
ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
|
|
|
shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());
|
|
@@ -211,14 +211,14 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 判断当前提交的购物车ID,有多少产品在售
|
|
|
int total = 0; // 支付金额
|
|
|
int sum = 0; // 产品数量
|
|
|
int productNum = 0; //计算商品为滤芯的数量
|
|
|
int machineNum = 0; //计算商品为水机的数量
|
|
|
boolean disable = true; //标识,是否可用优惠券,当购买商品只有滤芯时禁止使用优惠券
|
|
|
-
|
|
|
+
|
|
|
List<CartDto> tempCarts = new ArrayList<CartDto>();
|
|
|
|
|
|
//查询系统规则表滤芯id信息
|
|
@@ -235,6 +235,49 @@ public class OrderHandler {
|
|
|
String rolesStr = machine.split(":")[1];
|
|
|
machines = rolesStr.split(",");
|
|
|
}
|
|
|
+
|
|
|
+ String userQrcodeType = request.getParameter("userQrcodeType");
|
|
|
+ //存在水机时赠送4个滤芯
|
|
|
+ if(userQrcodeType != null && !"".equals(userQrcodeType)){
|
|
|
+
|
|
|
+ //如果是扫描优惠二维码进来,则显示优惠价并赠送滤芯
|
|
|
+ QrcodeGift gift = new QrcodeGift();
|
|
|
+ gift.setQrcodeStatus(1);
|
|
|
+ List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
|
|
|
+ if (giftList != null && giftList.size() > 0 && cartDtos != null && cartDtos.size() > 0) {
|
|
|
+ for (CartDto cartDto : cartDtos) {
|
|
|
+ for (QrcodeGift qrcodeGift : giftList) {
|
|
|
+ if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
|
|
|
+ switch (userQrcodeType) {
|
|
|
+ case "1":
|
|
|
+ if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
|
|
|
+ cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
+ }
|
|
|
+ if (qrcodeGift.getQrcodePreGiftColor() != null) {
|
|
|
+ for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
+ preGift.append(qrcodeGift.getQrcodePreGiftColor());
|
|
|
+ preGift.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
|
|
|
+ cartDto.setProductPrice(qrcodeGift.getQrcodeSalesDiscount());
|
|
|
+ }
|
|
|
+ if (qrcodeGift.getQrcodeSalesGiftColor() != null) {
|
|
|
+ for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
+ preGift.append(qrcodeGift.getQrcodeSalesGiftColor());
|
|
|
+ preGift.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for (CartDto cartDto : cartDtos) {
|
|
|
if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
|
|
|
total += cartDto.getCartNum() * cartDto.getProductPrice();
|
|
@@ -254,83 +297,43 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- String userQrcodeType = request.getParameter("userQrcodeType");
|
|
|
- //存在水机时赠送4个滤芯
|
|
|
- if(userQrcodeType != null && !"".equals(userQrcodeType)){
|
|
|
-
|
|
|
- //如果是扫描优惠二维码进来,则显示优惠价并赠送滤芯
|
|
|
- QrcodeGift gift = new QrcodeGift();
|
|
|
- List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
|
|
|
- if (giftList != null && giftList.size() > 0 && cartDtos != null && cartDtos.size() > 0) {
|
|
|
- for (CartDto cartDto : cartDtos) {
|
|
|
- for (QrcodeGift qrcodeGift : giftList) {
|
|
|
- if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
|
|
|
- switch (userQrcodeType) {
|
|
|
- case "1":
|
|
|
- if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
|
|
|
- cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
- }
|
|
|
- if (qrcodeGift.getQrcodePreGiftColor() != null) {
|
|
|
- for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
- preGift.append(qrcodeGift.getQrcodePreGiftColor());
|
|
|
- preGift.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
|
|
|
- cartDto.setProductPrice(qrcodeGift.getQrcodeSalesDiscount());
|
|
|
- }
|
|
|
- if (qrcodeGift.getQrcodeSalesGiftColor() != null) {
|
|
|
- for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
- preGift.append(qrcodeGift.getQrcodeSalesGiftColor());
|
|
|
- preGift.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if(preGift.toString() != null && !"".equals(preGift.toString())){
|
|
|
- String[] giftss = preGift.toString().split(",");
|
|
|
- ProductColor color = new ProductColor();
|
|
|
- color.setPage(null);
|
|
|
- List<ProductColor> colorList = productColorService.selectProductColorList(color);
|
|
|
- for (int i = 0;i < giftss.length;i++) {
|
|
|
- boolean cartFlag = false;
|
|
|
- for (CartDto cart : tempCarts) {
|
|
|
- //判断是否已经存在该赠品,如果存在则数量加1
|
|
|
- if (Integer.parseInt(giftss[i]) == cart.getCartColorId() && cart.getTotal() == 0) {
|
|
|
- cart.setCartNum(cart.getCartNum().intValue() + 1);
|
|
|
- cartFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- //如果不存在,则新增赠品
|
|
|
- if (!cartFlag) {
|
|
|
- for (ProductColor productColor : colorList) {
|
|
|
- if (Integer.parseInt(giftss[i]) == productColor.getColorId()) {
|
|
|
- CartDto cartDto = new CartDto();
|
|
|
- cartDto.setCartOpenId(member.getUserOpenid());
|
|
|
- cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
- cartDto.setCartColorId(productColor.getColorId());
|
|
|
- cartDto.setCartNum(1);
|
|
|
- cartDto.setCartCreateDate(new Date());
|
|
|
- cartDto.setProductName(productColor.getColorProductName());
|
|
|
- cartDto.setProductType(productColor.getColorProductType());
|
|
|
- cartDto.setProductPrice(0);
|
|
|
- cartDto.setProductIntroduceImg(productColor.getColorProductPic());
|
|
|
- cartDto.setTotal(0);
|
|
|
- cartDto.setProductDiscount(0);
|
|
|
- cartDto.setProductRemark("赠送滤芯");
|
|
|
- cartDto.setProductColor(productColor.getColorName());
|
|
|
- tempCarts.add(cartDto);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if(preGift.toString() != null && !"".equals(preGift.toString())){
|
|
|
+ String[] giftss = preGift.toString().split(",");
|
|
|
+ ProductColor color = new ProductColor();
|
|
|
+ color.setPage(null);
|
|
|
+ List<ProductColor> colorList = productColorService.selectProductColorList(color);
|
|
|
+ for (int i = 0;i < giftss.length;i++) {
|
|
|
+ boolean cartFlag = false;
|
|
|
+ for (CartDto cart : tempCarts) {
|
|
|
+ //判断是否已经存在该赠品,如果存在则数量加1
|
|
|
+ if (Integer.parseInt(giftss[i]) == cart.getCartColorId() && cart.getTotal() == 0) {
|
|
|
+ cart.setCartNum(cart.getCartNum().intValue() + 1);
|
|
|
+ cartFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果不存在,则新增赠品
|
|
|
+ if (!cartFlag) {
|
|
|
+ for (ProductColor productColor : colorList) {
|
|
|
+ if (Integer.parseInt(giftss[i]) == productColor.getColorId()) {
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
+ cartDto.setCartOpenId(member.getUserOpenid());
|
|
|
+ cartDto.setCartProductId(productColor.getColorProductId());
|
|
|
+ cartDto.setCartColorId(productColor.getColorId());
|
|
|
+ cartDto.setCartNum(1);
|
|
|
+ cartDto.setCartCreateDate(new Date());
|
|
|
+ cartDto.setProductName(productColor.getColorProductName());
|
|
|
+ cartDto.setProductType(productColor.getColorProductType());
|
|
|
+ cartDto.setProductPrice(0);
|
|
|
+ cartDto.setProductIntroduceImg(productColor.getColorProductPic());
|
|
|
+ cartDto.setTotal(0);
|
|
|
+ cartDto.setProductDiscount(0);
|
|
|
+ cartDto.setProductRemark("赠送滤芯");
|
|
|
+ cartDto.setProductColor(productColor.getColorName());
|
|
|
+ tempCarts.add(cartDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -338,14 +341,14 @@ public class OrderHandler {
|
|
|
if(productNum == cartDtos.size()) {
|
|
|
disable = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (sum <= 0) {
|
|
|
msg.setMessage(ResultInfo.cartEmptyError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//未使用的优惠券
|
|
|
- CouponItemDto cDto = new CouponItemDto();
|
|
|
+ CouponItemDto cDto = new CouponItemDto();
|
|
|
cDto.setUseropenid(member.getUserOpenid());
|
|
|
cDto.setCouponUseStatus(1);
|
|
|
cDto.setBeginDate(new Date());
|
|
@@ -353,18 +356,18 @@ public class OrderHandler {
|
|
|
cDto.getPage().setPageSize(12);
|
|
|
//cDto.getPage().setPageNumber(pageNO);
|
|
|
List<CouponItemDto> list = couponItemService.getCouponItemDtoList(cDto);
|
|
|
-
|
|
|
+
|
|
|
dto.setCouponItems(list);
|
|
|
-
|
|
|
+
|
|
|
dto.setCartId(cartIds);// 购物车ID
|
|
|
dto.setPayTotal(total); // 支付金额,单位为分
|
|
|
dto.setCartItems(tempCarts); // 订单项
|
|
|
dto.setSuccess(true); // 请求成功
|
|
|
dto.setMeonyProportion(0);
|
|
|
dto.setBalance(member.getUserIncome());
|
|
|
-
|
|
|
+
|
|
|
dto.setDisable(disable);
|
|
|
-
|
|
|
+
|
|
|
//回显用户支付过的地址信息
|
|
|
Order order=cartService.getOrderRecentAddress(member.getUserOpenid());
|
|
|
if(order!=null){
|
|
@@ -376,30 +379,30 @@ public class OrderHandler {
|
|
|
map.put("salesAddressPostnum", order.getSalesAddressPostnum());
|
|
|
dto.setAddressInfo(map);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
msg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
msg.setData(dto);
|
|
|
msg.setStatus(true);
|
|
|
-
|
|
|
+
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 发起支付请求
|
|
|
* @return
|
|
|
- * @throws Exception
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/pay", method = RequestMethod.POST)
|
|
|
public ResultMsg requestPay(
|
|
|
TempOrderDto temp,
|
|
|
HttpServletRequest request
|
|
|
- ) throws Exception {
|
|
|
-
|
|
|
+ ) throws Exception {
|
|
|
+
|
|
|
ResultMsg msg = new ResultMsg();
|
|
|
int machineNum = 0;//所有水机的数量
|
|
|
- StringBuilder preGift = new StringBuilder();
|
|
|
+ StringBuilder preGift = new StringBuilder();
|
|
|
msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
//当前支付时间
|
|
|
Date nowDate=new Date();
|
|
@@ -412,7 +415,7 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.loginOutError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
member=memberService.getMemberByUserId(member.getUserId());
|
|
|
if (!validatorUtil.validatorObject(temp)) { // 校验订单信息是否输入有误
|
|
|
msg.setMessage(ResultInfo.paramFormatError);
|
|
@@ -441,13 +444,13 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.cartEmptyError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//根据openid查询该用户是否购买过订单
|
|
|
ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
|
|
|
shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());
|
|
|
shopSalesOrderDto.setSalesStatus("2");
|
|
|
int orderNum = cartService.selectOrderCount(shopSalesOrderDto);
|
|
|
-
|
|
|
+
|
|
|
int total = 0; // 需要支付的总额, 单位为分
|
|
|
|
|
|
|
|
@@ -455,7 +458,7 @@ public class OrderHandler {
|
|
|
int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
|
|
|
UserGiftDto userGift = null;
|
|
|
int giftNum = 0;
|
|
|
-
|
|
|
+
|
|
|
/** 提前准备订单项数据 */
|
|
|
/** 准备数据 */
|
|
|
Order order = new Order();
|
|
@@ -463,10 +466,10 @@ public class OrderHandler {
|
|
|
List<OrderItem> list = new ArrayList<OrderItem>();
|
|
|
List<Integer> cartIds = new ArrayList<Integer>();
|
|
|
String userQrcodeType = request.getParameter("userQrcodeType");
|
|
|
- int num = productInfoService.getQrCodeByPlaceOpenId(member.getUserOpenid());
|
|
|
+ int num = productInfoService.getQrCodeByPlaceOpenId(member.getUserOpenid());
|
|
|
for (CartDto cartDto : cartDtos) {
|
|
|
|
|
|
- //如果是有二维码的商户,进入后显示优惠价
|
|
|
+ /*//如果是有二维码的商户,进入后显示优惠价
|
|
|
if (num > 0) {
|
|
|
QrcodeGift gift = new QrcodeGift();
|
|
|
List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
|
|
@@ -480,45 +483,46 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
if (userQrcodeType != null && !"".equals(userQrcodeType)) {
|
|
|
|
|
|
- //如果是扫描优惠二维码进来,则显示优惠价并赠送滤芯
|
|
|
- QrcodeGift gift = new QrcodeGift();
|
|
|
- List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
|
|
|
- if (giftList != null && giftList.size() > 0) {
|
|
|
- for (QrcodeGift qrcodeGift : giftList) {
|
|
|
- if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
|
|
|
- switch (userQrcodeType) {
|
|
|
- case "1":
|
|
|
- if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
|
|
|
- cartDto.setProductDiscount(qrcodeGift.getQrcodePreDiscount());
|
|
|
- cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
- }
|
|
|
- if (qrcodeGift.getQrcodePreGiftColor() != null) {
|
|
|
- for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
- preGift.append(qrcodeGift.getQrcodePreGiftColor());
|
|
|
- preGift.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- case "2":
|
|
|
- if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
|
|
|
- cartDto.setProductDiscount(qrcodeGift.getQrcodeSalesDiscount());
|
|
|
- cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
- }
|
|
|
- if (qrcodeGift.getQrcodeSalesGiftColor() != null) {
|
|
|
- for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
- preGift.append(qrcodeGift.getQrcodeSalesGiftColor());
|
|
|
- preGift.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //如果是扫描优惠二维码进来,则显示优惠价并赠送滤芯
|
|
|
+ QrcodeGift gift = new QrcodeGift();
|
|
|
+ gift.setQrcodeStatus(1);
|
|
|
+ List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
|
|
|
+ if (giftList != null && giftList.size() > 0) {
|
|
|
+ for (QrcodeGift qrcodeGift : giftList) {
|
|
|
+ if (cartDto.getCartColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
|
|
|
+ switch (userQrcodeType) {
|
|
|
+ case "1":
|
|
|
+ if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
|
|
|
+ cartDto.setProductDiscount(qrcodeGift.getQrcodePreDiscount());
|
|
|
+ cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
+ }
|
|
|
+ if (qrcodeGift.getQrcodePreGiftColor() != null) {
|
|
|
+ for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
+ preGift.append(qrcodeGift.getQrcodePreGiftColor());
|
|
|
+ preGift.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
|
|
|
+ cartDto.setProductDiscount(qrcodeGift.getQrcodeSalesDiscount());
|
|
|
+ cartDto.setProductPrice(qrcodeGift.getQrcodeSalesDiscount());
|
|
|
+ }
|
|
|
+ if (qrcodeGift.getQrcodeSalesGiftColor() != null) {
|
|
|
+ for (int i = 0;i < cartDto.getCartNum();i++) {
|
|
|
+ preGift.append(qrcodeGift.getQrcodeSalesGiftColor());
|
|
|
+ preGift.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//如果购买过订单,则滤芯的价格可按折扣价购买
|
|
@@ -535,9 +539,9 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//如果模板id等于金牌会模板id,则该用户为金牌会员下线
|
|
|
- if (member.getUserDealers() != null && member.getTemplateId() != null
|
|
|
+ if (member.getUserDealers() != null && member.getTemplateId() != null
|
|
|
&& templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
|
|
|
UserGiftDto userGiftDto = new UserGiftDto();
|
|
|
userGiftDto.setUserLevel(2);
|
|
@@ -553,7 +557,7 @@ public class OrderHandler {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
|
|
|
cartIds.add(cartDto.getCartId());
|
|
|
Integer subTotal = cartDto.getCartNum() * cartDto.getProductPrice(); // 小计
|
|
@@ -575,43 +579,43 @@ public class OrderHandler {
|
|
|
|
|
|
//扫描优惠二维码赠送赠品信息
|
|
|
if (preGift != null && !"".equals(preGift.toString())) {
|
|
|
- String[] giftss = preGift.toString().split(",");
|
|
|
- ProductColor color = new ProductColor();
|
|
|
- color.setPage(null);
|
|
|
- List<ProductColor> colorList = productColorService.selectProductColorList(color);
|
|
|
- for (int i = 0;i < giftss.length;i++) {
|
|
|
- boolean cartFlag = false;
|
|
|
- for (OrderItem item : list) {
|
|
|
- //判断是否已经存在该赠品,如果存在则数量加1
|
|
|
- if (Integer.parseInt(giftss[i]) == item.getItemColorId() && item.getItemTotal() == 0) {
|
|
|
- item.setItemNum(item.getItemNum().intValue() + 1);
|
|
|
- cartFlag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- //如果不存在,则新增订单项
|
|
|
- if (!cartFlag) {
|
|
|
- for (ProductColor productColor : colorList) {
|
|
|
- if (Integer.parseInt(giftss[i]) == productColor.getColorId()) {
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
- orderItem.setItemNum(1);
|
|
|
- orderItem.setItemProductDiscount(0);
|
|
|
- orderItem.setItemProductId(productColor.getColorProductId());
|
|
|
- orderItem.setItemProductName(productColor.getColorProductName());
|
|
|
- orderItem.setItemProductPic(productColor.getColorProductPic());
|
|
|
- orderItem.setItemSalesOrderid(order.getSalesOrderid());
|
|
|
- orderItem.setItemTotal(0);
|
|
|
- orderItem.setItemProductType(productColor.getColorProductType());
|
|
|
- orderItem.setItemProductPrice(0);
|
|
|
- orderItem.setItemColorId(productColor.getColorId());
|
|
|
- list.add(orderItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ String[] giftss = preGift.toString().split(",");
|
|
|
+ ProductColor color = new ProductColor();
|
|
|
+ color.setPage(null);
|
|
|
+ List<ProductColor> colorList = productColorService.selectProductColorList(color);
|
|
|
+ for (int i = 0;i < giftss.length;i++) {
|
|
|
+ boolean cartFlag = false;
|
|
|
+ for (OrderItem item : list) {
|
|
|
+ //判断是否已经存在该赠品,如果存在则数量加1
|
|
|
+ if (Integer.parseInt(giftss[i]) == item.getItemColorId() && item.getItemTotal() == 0) {
|
|
|
+ item.setItemNum(item.getItemNum().intValue() + 1);
|
|
|
+ cartFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果不存在,则新增订单项
|
|
|
+ if (!cartFlag) {
|
|
|
+ for (ProductColor productColor : colorList) {
|
|
|
+ if (Integer.parseInt(giftss[i]) == productColor.getColorId()) {
|
|
|
+ OrderItem orderItem = new OrderItem();
|
|
|
+ orderItem.setItemNum(1);
|
|
|
+ orderItem.setItemProductDiscount(0);
|
|
|
+ orderItem.setItemProductId(productColor.getColorProductId());
|
|
|
+ orderItem.setItemProductName(productColor.getColorProductName());
|
|
|
+ orderItem.setItemProductPic(productColor.getColorProductPic());
|
|
|
+ orderItem.setItemSalesOrderid(order.getSalesOrderid());
|
|
|
+ orderItem.setItemTotal(0);
|
|
|
+ orderItem.setItemProductType(productColor.getColorProductType());
|
|
|
+ orderItem.setItemProductPrice(0);
|
|
|
+ orderItem.setItemColorId(productColor.getColorId());
|
|
|
+ list.add(orderItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//如果模板id等于金牌会模板id,来源是3,则该用户为金牌会员直接下线,直接下线送三年滤芯
|
|
|
- if (member.getUserDealers() != null && member.getTemplateId() != null &&
|
|
|
+ if (member.getUserDealers() != null && member.getTemplateId() != null &&
|
|
|
templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
|
|
|
//当userGift不为空时,说明该用户购买的商品有奖励礼品,奖励礼品取第一个产品的,不适用于多个产品有不同奖励礼品的情况
|
|
|
if (userGift != null && userGift.getUserGiftId() != null && !"".equals(userGift.getUserGiftId())) {
|
|
@@ -630,13 +634,13 @@ public class OrderHandler {
|
|
|
list.add(orderItem);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 准备订单对象
|
|
|
order.setSalesOpenid(member.getUserOpenid()); // openid
|
|
|
order.setSalesAmount(total); // 订单金额
|
|
|
-
|
|
|
+
|
|
|
int mustPay=0;
|
|
|
-
|
|
|
+
|
|
|
String couponId=temp.getCouponId();
|
|
|
CouponItemDto couponItemDto=new CouponItemDto();
|
|
|
CouponItem couponItem=new CouponItem();
|
|
@@ -652,7 +656,7 @@ public class OrderHandler {
|
|
|
couponItem.setCouponItemUseropenid(couponItemDto.getUseropenid());
|
|
|
couponItem.setCouponUseEndDate(couponItemDto.getCouponUseEndDate());
|
|
|
couponItem.setCouponUseDate(couponItemDto.getCouponUseDate());
|
|
|
-
|
|
|
+
|
|
|
if(null==couponItemDto || !couponItemDto.getUseropenid().equals(member.getUserOpenid()) || couponItemDto.getCouponUseStatus()!=1){
|
|
|
msg.setMessage(ResultInfo.COUPON_INVALID); //优惠券无效
|
|
|
return msg;
|
|
@@ -661,7 +665,7 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.COUPON_OUTOFDATE); //优惠券过期
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//消费达到指定额度
|
|
|
CouponType couponType = couponTypeService.getCouponTypeById(couponItemDto.getCouponId());
|
|
|
if(couponType.getCouponConsumeEnough()>total){
|
|
@@ -674,7 +678,7 @@ public class OrderHandler {
|
|
|
}else if(couponType.getCouponType()==2){
|
|
|
total=total*couponType.getCouponReduce()/100;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if(total==0 || total<0){
|
|
|
total=0;
|
|
@@ -682,7 +686,7 @@ public class OrderHandler {
|
|
|
}else{
|
|
|
mustPay=total;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//获取账户余额,判断是否在可用范围内
|
|
|
int balancePayAmount=temp.getBalancePayAmount();
|
|
|
if(balancePayAmount>0 && member.getUserIncome()>balancePayAmount){
|
|
@@ -691,7 +695,7 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.NO_ENOUGH_FOR_PAY);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
order.setSalesYetAmount(total);
|
|
|
order.setSalesRateAmount(0);
|
|
|
order.setSalesIntegralNum(temp.getOrderIntegralNum()); // 订单使用积分
|
|
@@ -723,7 +727,7 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.paramFormatError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
boolean updateFlase=false;
|
|
|
if (flag && mustPay>0) {
|
|
|
// 发起支付
|
|
@@ -751,7 +755,7 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.paramFormatError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(updateFlase){
|
|
|
//设置订单状态,还有优惠券id
|
|
|
order.setSalesStatus(2);
|
|
@@ -762,12 +766,12 @@ public class OrderHandler {
|
|
|
couponItem.setCouponUseDate(new Date());//添加使用时间
|
|
|
int i=couponItemService.updateCouponItemById(couponItem);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//更新账户余额
|
|
|
if(balancePayAmount>0){
|
|
|
member.setUserIncome(-balancePayAmount);
|
|
|
memberService.updateUserIncomeByOpenId(member);
|
|
|
-
|
|
|
+
|
|
|
//修改用户购买记录为已购买
|
|
|
memberService.updateIsBaughtByOpenid(member.getUserOpenid(), 2);
|
|
|
//更新用户绑定状态
|
|
@@ -780,7 +784,7 @@ public class OrderHandler {
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("为用户生成二维码失败!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//现金使用记录
|
|
|
CashLog log=new CashLog();
|
|
|
log.setCashLogsIntroduction("订单支出");
|
|
@@ -791,21 +795,21 @@ public class OrderHandler {
|
|
|
log.setCashLogsOrderid(order.getSalesOrderid());
|
|
|
log.setCashLogsCreateDate(nowDate);
|
|
|
cashLogService.addCashLog(log);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
rebackServices.loadSingleOrderReward(order);
|
|
|
productInfoService.updateProductNumList(order.getSalesOrderid());
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
msg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
dto.setOrderId(order.getSalesOrderid());
|
|
|
msg.setData(dto);
|
|
|
msg.setStatus(true);
|
|
|
-
|
|
|
+
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 校验订单状态,判断是否支付成功
|
|
|
* @param orderId
|
|
@@ -827,7 +831,7 @@ public class OrderHandler {
|
|
|
msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
msg.setMessage(NameUtils.getConfig("ERRORINFO"));
|
|
|
msg.setStatus(false);
|
|
|
-
|
|
|
+
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
@@ -835,7 +839,7 @@ public class OrderHandler {
|
|
|
public void paySuccess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
request.getRequestDispatcher(NameUtils.getConfig("WECHAT_SHOP_ORDER_PAY_SUCCESS")).forward(request, response);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@RequestMapping(value = "/getOrderInfo", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public ResultMsg getOrderInfoByOrderId(
|
|
@@ -848,24 +852,24 @@ public class OrderHandler {
|
|
|
order.setSalesOrderid(orderId);
|
|
|
order.setSalesOpenid(member.getUserOpenid());
|
|
|
order = cartService.selectOrderInfoById(order);
|
|
|
-
|
|
|
+
|
|
|
if (order == null || order.getSalesStatus() != 2) {
|
|
|
msg.setMessage(ResultInfo.paramFormatError);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
msg.setData(order);
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
msg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
|
|
|
msg.setStatus(true);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 校验一个购物车字符串
|
|
|
* @param cartIds 购物车ID字符串
|
|
|
* @return
|
|
|
- * @throws Exception
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
public Integer[] checkCartIdListString(String cartIds) throws Exception {
|
|
|
if (cartIds == null) {
|