|
@@ -63,7 +63,8 @@ import com.iamberry.wechat.tools.ValidatorUtil;
|
|
|
* Update Date:2016年4月20日
|
|
|
*/
|
|
|
@Controller
|
|
|
-@RequestMapping("/wechat/order")
|
|
|
+
|
|
|
+@RequestMapping("/order")
|
|
|
public class OrderHandler {
|
|
|
|
|
|
@Autowired
|
|
@@ -104,7 +105,7 @@ public class OrderHandler {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequestMapping(value = "/payBefore", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/payBefore")
|
|
|
public ResultMsg payBefore(HttpServletRequest request) throws Exception {
|
|
|
|
|
|
ResultMsg msg = new ResultMsg();
|
|
@@ -244,7 +245,12 @@ public class OrderHandler {
|
|
|
|
|
|
SendPayDto dto = new SendPayDto();
|
|
|
dto.setSuccess(false);
|
|
|
- Member member = WechatUtils.getUserBySession(request);
|
|
|
+
|
|
|
+
|
|
|
+ Member member = new Member();
|
|
|
+ member.setUserId(14708);
|
|
|
+ member.setUserOpenid("oZ9pv02WMRQgyDVRY1a_daYecwHI");
|
|
|
+
|
|
|
|
|
|
if (member == null || member.getUserOpenid() == null) {
|
|
|
msg.setMessage(ResultInfo.loginOutError);
|
|
@@ -280,119 +286,18 @@ public class OrderHandler {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
|
|
|
- shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());
|
|
|
- shopSalesOrderDto.setSalesStatus("2");
|
|
|
- int orderNum = cartService.selectOrderCount(shopSalesOrderDto);
|
|
|
+
|
|
|
+ boolean isContainProduct = false;
|
|
|
|
|
|
int total = 0;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
|
|
|
- UserGiftDto userGift = null;
|
|
|
- int giftNum = 0;
|
|
|
-
|
|
|
|
|
|
|
|
|
Order order = new Order();
|
|
|
order.setSalesOrderid(OrderNOUtil.createOrderCode(member.getUserId()));
|
|
|
List<OrderItem> list = new ArrayList<OrderItem>();
|
|
|
List<Integer> cartIds = new ArrayList<Integer>();
|
|
|
- String userQrcodeType = request.getParameter("userQrcodeType");
|
|
|
int num = productInfoService.getQrCodeByPlaceOpenId(member.getUserOpenid());
|
|
|
for (CartDto cartDto : cartDtos) {
|
|
|
-
|
|
|
-
|
|
|
- if (num > 0) {
|
|
|
- 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()
|
|
|
- && qrcodeGift.getQrcodePreDiscount() != null
|
|
|
- && qrcodeGift.getQrcodePreDiscount() > 0) {
|
|
|
- cartDto.setProductDiscount(qrcodeGift.getQrcodePreDiscount());
|
|
|
- cartDto.setProductPrice(qrcodeGift.getQrcodePreDiscount());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- if (userQrcodeType != null && !"".equals(userQrcodeType)) {
|
|
|
-
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (orderNum > 0) {
|
|
|
- if (cartDto.getProductType().intValue() == 2) {
|
|
|
- UserGiftDto userGiftDto = new UserGiftDto();
|
|
|
- userGiftDto.setUserLevel(3);
|
|
|
- userGiftDto.setUserProductId(cartDto.getCartProductId());
|
|
|
- userGiftDto.setUserColorId(cartDto.getCartColorId());
|
|
|
-
|
|
|
- userGiftDto = productInfoService.selectUserGift(userGiftDto);
|
|
|
- if (userGiftDto != null) {
|
|
|
- cartDto.setProductPrice(userGiftDto.getUserDiscount());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (member.getUserDealers() != null && member.getTemplateId() != null
|
|
|
- && templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
|
|
|
- UserGiftDto userGiftDto = new UserGiftDto();
|
|
|
- userGiftDto.setUserLevel(2);
|
|
|
- userGiftDto.setUserProductId(cartDto.getCartProductId());
|
|
|
- userGiftDto.setUserColorId(cartDto.getCartColorId());
|
|
|
-
|
|
|
- userGiftDto = productInfoService.selectUserGift(userGiftDto);
|
|
|
- if (userGiftDto != null) {
|
|
|
- cartDto.setProductPrice(userGiftDto.getUserDiscount());
|
|
|
- giftNum += cartDto.getCartNum();
|
|
|
- if (userGift == null) {
|
|
|
- userGift = userGiftDto;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
|
|
|
cartIds.add(cartDto.getCartId());
|
|
|
Integer subTotal = cartDto.getCartNum() * cartDto.getProductPrice();
|
|
@@ -410,63 +315,8 @@ public class OrderHandler {
|
|
|
item.setItemColorId(cartDto.getCartColorId());
|
|
|
list.add(item);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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) {
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (member.getUserDealers() != null && member.getTemplateId() != null &&
|
|
|
- templateId == member.getTemplateId().intValue() && member.getUserResType().intValue() == 3) {
|
|
|
-
|
|
|
- if (userGift != null && userGift.getUserGiftId() != null && !"".equals(userGift.getUserGiftId())) {
|
|
|
- Product product = productInfoService.getProductByProductId(userGift.getUserGiftId(),userGift.getUserGiftColor());
|
|
|
- OrderItem orderItem = new OrderItem();
|
|
|
- orderItem.setItemNum(userGift.getUserGiftCount() * giftNum);
|
|
|
- orderItem.setItemProductDiscount(0);
|
|
|
- orderItem.setItemProductId(userGift.getUserGiftId());
|
|
|
- orderItem.setItemProductName(product.getProductName());
|
|
|
- orderItem.setItemProductPic(product.getProductIntroduceImg());
|
|
|
- orderItem.setItemSalesOrderid(order.getSalesOrderid());
|
|
|
- orderItem.setItemTotal(0);
|
|
|
- orderItem.setItemProductType(product.getProductType().getTypeId());
|
|
|
- orderItem.setItemProductPrice(0);
|
|
|
- orderItem.setItemColorId(userGift.getUserColorId());
|
|
|
- list.add(orderItem);
|
|
|
+ if(cartDto.getProductType() == 100){
|
|
|
+ isContainProduct = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -491,6 +341,7 @@ public class OrderHandler {
|
|
|
couponItem.setCouponItemUseropenid(couponItemDto.getUseropenid());
|
|
|
couponItem.setCouponUseEndDate(couponItemDto.getCouponUseEndDate());
|
|
|
couponItem.setCouponUseDate(couponItemDto.getCouponUseDate());
|
|
|
+ couponItem.setCouponIsNewPeople(couponItemDto.getCouponIsNewPeople());
|
|
|
|
|
|
if(null==couponItemDto || !couponItemDto.getUseropenid().equals(member.getUserOpenid()) || couponItemDto.getCouponUseStatus()!=1){
|
|
|
msg.setMessage(ResultInfo.COUPON_INVALID);
|
|
@@ -500,20 +351,25 @@ public class OrderHandler {
|
|
|
msg.setMessage(ResultInfo.COUPON_OUTOFDATE);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
CouponType couponType = couponTypeService.getCouponTypeById(couponItemDto.getCouponId());
|
|
|
if(couponType.getCouponConsumeEnough()>total){
|
|
|
msg.setMessage(ResultInfo.COUPON_CONSUME_NO_ENOUGH);
|
|
|
return msg;
|
|
|
}
|
|
|
-
|
|
|
+ if(member.getUserIdentity() != 1){
|
|
|
+ if(couponItem.getCouponIsNewPeople() == 1 && !isContainProduct){
|
|
|
+ msg.setMessage(ResultInfo.COUPON_NO_MEMBER);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(couponType.getCouponType()==1){
|
|
|
total=total-couponType.getCouponReduce();
|
|
|
}else if(couponType.getCouponType()==2){
|
|
|
+ Integer all = new Integer(total);
|
|
|
total=total*couponType.getCouponReduce()/100;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if(total==0 || total<0){
|
|
|
total=0;
|
|
@@ -522,20 +378,11 @@ public class OrderHandler {
|
|
|
mustPay=total;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- int balancePayAmount=temp.getBalancePayAmount();
|
|
|
- if(balancePayAmount>0 && member.getUserIncome()>balancePayAmount){
|
|
|
- mustPay=total-temp.getBalancePayAmount()>0?total-temp.getBalancePayAmount():0;
|
|
|
- }else if(balancePayAmount>0 && member.getUserIncome()<balancePayAmount){
|
|
|
- msg.setMessage(ResultInfo.NO_ENOUGH_FOR_PAY);
|
|
|
- return msg;
|
|
|
- }
|
|
|
-
|
|
|
order.setSalesYetAmount(total);
|
|
|
order.setSalesRateAmount(0);
|
|
|
- order.setSalesIntegralNum(temp.getOrderIntegralNum());
|
|
|
+ order.setSalesIntegralNum(0);
|
|
|
order.setSalesCreateDate(new Date());
|
|
|
- order.setBalancePayAmount(temp.getBalancePayAmount());
|
|
|
+ order.setBalancePayAmount(0);
|
|
|
order.setCouponId(couponId);
|
|
|
|
|
|
order.setSalesStatus(1);
|
|
@@ -550,7 +397,7 @@ public class OrderHandler {
|
|
|
boolean flag = false;
|
|
|
try {
|
|
|
flag = cartService.addOrderAndSaveOrderItem(order, list, cartIds);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if(hasCoupon){
|
|
|
couponItem.setCouponUseStatus(7);
|
|
@@ -601,40 +448,7 @@ 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);
|
|
|
-
|
|
|
- if (member.getUserIsFlag()!= null && member.getUserIsFlag() == 1) {
|
|
|
- member.setUserIsFlag(2);
|
|
|
- homeService.updateMemberIsFlagByOpenid(member);
|
|
|
- }
|
|
|
- try {
|
|
|
- temporaryQrcodeService.applyTempQrcode(member.getUserOpenid());
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("为用户生成二维码失败!");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- CashLog log=new CashLog();
|
|
|
- log.setCashLogsIntroduction("订单支出");
|
|
|
- log.setCashLogsNum(balancePayAmount);
|
|
|
- log.setCashLogsOpenid(member.getUserOpenid());
|
|
|
- log.setCashLogsType(2);
|
|
|
- log.setCashLogsResType(3);
|
|
|
- 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"));
|