|
@@ -13,6 +13,7 @@ import com.iamberry.wechat.core.entity.channel.ChildChannel;
|
|
import com.iamberry.wechat.core.entity.channel.MainChannel;
|
|
import com.iamberry.wechat.core.entity.channel.MainChannel;
|
|
import com.iamberry.wechat.core.entity.coupon.*;
|
|
import com.iamberry.wechat.core.entity.coupon.*;
|
|
import com.iamberry.wechat.core.entity.customized.CustomizedTooth;
|
|
import com.iamberry.wechat.core.entity.customized.CustomizedTooth;
|
|
|
|
+import com.iamberry.wechat.core.entity.gift.SettlementGift;
|
|
import com.iamberry.wechat.core.entity.integral.StayIntegral;
|
|
import com.iamberry.wechat.core.entity.integral.StayIntegral;
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
import com.iamberry.wechat.core.entity.member.Member;
|
|
import com.iamberry.wechat.core.entity.order.Order;
|
|
import com.iamberry.wechat.core.entity.order.Order;
|
|
@@ -31,6 +32,7 @@ import com.iamberry.wechat.face.coupon.CouponItemService;
|
|
import com.iamberry.wechat.face.coupon.CouponTypeService;
|
|
import com.iamberry.wechat.face.coupon.CouponTypeService;
|
|
import com.iamberry.wechat.face.coupon.SalesActivitiesService;
|
|
import com.iamberry.wechat.face.coupon.SalesActivitiesService;
|
|
import com.iamberry.wechat.face.customized.CustomizedToothService;
|
|
import com.iamberry.wechat.face.customized.CustomizedToothService;
|
|
|
|
+import com.iamberry.wechat.face.gift.SettlementGiftService;
|
|
import com.iamberry.wechat.face.home.HomeService;
|
|
import com.iamberry.wechat.face.home.HomeService;
|
|
import com.iamberry.wechat.face.integral.UseIntegralService;
|
|
import com.iamberry.wechat.face.integral.UseIntegralService;
|
|
import com.iamberry.wechat.face.member.CashLogService;
|
|
import com.iamberry.wechat.face.member.CashLogService;
|
|
@@ -47,6 +49,7 @@ import com.iamberry.wechat.tools.OrderNOUtil;
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
import com.iamberry.wechat.tools.ValidatorUtil;
|
|
import com.iamberry.wechat.tools.ValidatorUtil;
|
|
import com.iamberry.wechat.utils.ActivityUtil;
|
|
import com.iamberry.wechat.utils.ActivityUtil;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -73,19 +76,14 @@ import java.util.regex.Pattern;
|
|
public class OrderHandler {
|
|
public class OrderHandler {
|
|
@Autowired
|
|
@Autowired
|
|
private RatFWLogger ratFWLogger;
|
|
private RatFWLogger ratFWLogger;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private CartService cartService;
|
|
private CartService cartService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private HomeService homeService;
|
|
private HomeService homeService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SystemService systemService;
|
|
private SystemService systemService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ValidatorUtil validatorUtil;
|
|
private ValidatorUtil validatorUtil;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private PayService payService;
|
|
private PayService payService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -126,6 +124,8 @@ public class OrderHandler {
|
|
private ActivityUtil activityUtil;
|
|
private ActivityUtil activityUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private SalesActivitiesService salesActivitiesService;
|
|
private SalesActivitiesService salesActivitiesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SettlementGiftService settlementGiftService;
|
|
|
|
|
|
|
|
|
|
* 支付前,调用方法
|
|
* 支付前,调用方法
|
|
@@ -155,7 +155,7 @@ public class OrderHandler {
|
|
|
|
|
|
if(channelType > 0 && channelId > 0){
|
|
if(channelType > 0 && channelId > 0){
|
|
if(channelType == 1){
|
|
if(channelType == 1){
|
|
- MainChannel mainChannel = mainChannelService.getMainChannelById(channelId);
|
|
+ MainChannel mainChannel = mainChannelService.getMainChannelById(channelId);
|
|
dto.setChannelName(mainChannel.getMainChannelName());
|
|
dto.setChannelName(mainChannel.getMainChannelName());
|
|
}else{
|
|
}else{
|
|
ChildChannel childChannel = childChannelService.getChildChannelById(channelId);
|
|
ChildChannel childChannel = childChannelService.getChildChannelById(channelId);
|
|
@@ -230,35 +230,15 @@ public class OrderHandler {
|
|
}
|
|
}
|
|
|
|
|
|
ActivityDate activityDate = activityUtil.doubleTwelve();
|
|
ActivityDate activityDate = activityUtil.doubleTwelve();
|
|
- if(channelType > 0 && channelId > 0){
|
|
+ if(channelType > 0 && channelId > 0){
|
|
activityDate.setStatus(false);
|
|
activityDate.setStatus(false);
|
|
}else{
|
|
}else{
|
|
-
|
|
|
|
if(activityDate.isStatus()){
|
|
if(activityDate.isStatus()){
|
|
|
|
+
|
|
|
|
+ Integer promotionAmout = fullReduc(activityDate,allAmount);;
|
|
|
|
|
|
-
|
|
+
|
|
- Integer promotionAmout = allAmount;
|
|
+ giftCart(cartDtos);
|
|
-
|
|
|
|
- SalesActivities sa = new SalesActivities();
|
|
|
|
- sa.setSalesActivitiesStatus(1);
|
|
|
|
- sa.setSalesActivitiesType(1);
|
|
|
|
- sa.setSalesActivitiesScenes(1);
|
|
|
|
- List<SalesActivities> salesActivitiesList = salesActivitiesService.getSalesActivitiesList(sa);
|
|
|
|
- activityDate.setSalesActivitiesList(salesActivitiesList);
|
|
|
|
- for (SalesActivities salesActivities : activityDate.getSalesActivitiesList()){
|
|
|
|
- if(promotionAmout >= salesActivities.getSalesActivitiesFull()){
|
|
|
|
- promotionAmout = allAmount - salesActivities.getSalesActivitiesReduction();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Integer num[] = new Integer[0];
|
|
|
|
- if(toothKidsbrush > 0){
|
|
|
|
- addFullReduction(5,cartDtos,num);
|
|
|
|
- }
|
|
|
|
- if(toothAuthbrush > 0 || toothKidsbrush > 0){
|
|
|
|
- num = new Integer[]{toothKidsbrush+toothAuthbrush};
|
|
|
|
- addFullReduction(1,cartDtos,num);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
dto.setActivityDate(activityDate);
|
|
dto.setActivityDate(activityDate);
|
|
@@ -341,9 +321,6 @@ public class OrderHandler {
|
|
cDto.setUseropenid(member.getUserOpenid());
|
|
cDto.setUseropenid(member.getUserOpenid());
|
|
cDto.setCouponUseStatus(1);
|
|
cDto.setCouponUseStatus(1);
|
|
cDto.setBeginDate(new Date());
|
|
cDto.setBeginDate(new Date());
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
List<CouponItemDto> couponItemDtoList = couponItemService.getCouponItemDtoList(cDto);
|
|
List<CouponItemDto> couponItemDtoList = couponItemService.getCouponItemDtoList(cDto);
|
|
List<CouponItemDto> list = new ArrayList<>();
|
|
List<CouponItemDto> list = new ArrayList<>();
|
|
for(CouponItemDto couponItemDto : couponItemDtoList){
|
|
for(CouponItemDto couponItemDto : couponItemDtoList){
|
|
@@ -534,35 +511,15 @@ public class OrderHandler {
|
|
allAmount += cd.getCartNum()*cd.getProductPrice();
|
|
allAmount += cd.getCartNum()*cd.getProductPrice();
|
|
}
|
|
}
|
|
|
|
|
|
- if(temp.getChannelType() > 0 && temp.getChannelId() > 0){
|
|
+ if(temp.getChannelType() > 0 && temp.getChannelId() > 0){
|
|
activityDate.setStatus(false);
|
|
activityDate.setStatus(false);
|
|
}else {
|
|
}else {
|
|
-
|
|
|
|
- Integer promotionAmout = allAmount;
|
|
|
|
-
|
|
|
|
- SalesActivities sa = new SalesActivities();
|
|
|
|
- sa.setSalesActivitiesStatus(1);
|
|
|
|
- sa.setSalesActivitiesType(1);
|
|
|
|
- sa.setSalesActivitiesScenes(1);
|
|
|
|
- List<SalesActivities> salesActivitiesList = salesActivitiesService.getSalesActivitiesList(sa);
|
|
|
|
- activityDate.setSalesActivitiesList(salesActivitiesList);
|
|
|
|
- for (SalesActivities salesActivities : activityDate.getSalesActivitiesList()){
|
|
|
|
- if(promotionAmout >= salesActivities.getSalesActivitiesFull()){
|
|
|
|
- promotionAmout = allAmount - salesActivities.getSalesActivitiesReduction();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
if (activityDate.isStatus()) {
|
|
if (activityDate.isStatus()) {
|
|
- Integer num[] = new Integer[0];
|
|
+
|
|
- if(toothKidsbrush > 0){
|
|
+ Integer promotionAmout = fullReduc(activityDate,allAmount);;
|
|
- addFullReduction(5,cartDtos,num);
|
|
+
|
|
- }
|
|
+
|
|
- if(toothAuthbrush > 0 || toothKidsbrush > 0){
|
|
+ giftCart(cartDtos);
|
|
- num = new Integer[]{toothKidsbrush+toothAuthbrush};
|
|
|
|
- addFullReduction(1,cartDtos,num);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if("2".equals(temp.getIsCustomize())){
|
|
}else if("2".equals(temp.getIsCustomize())){
|
|
@@ -1135,58 +1092,158 @@ public class OrderHandler {
|
|
* @param
|
|
* @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private void addCartDtos(List<CartDto> cartDtos,Integer id,Integer num){
|
|
+
|
|
- boolean flag = false;
|
|
+
|
|
- for (CartDto cartDto : cartDtos) {
|
|
+
|
|
- if(id.equals(cartDto.getCartColorId())){
|
|
+
|
|
- flag = true;
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 获取赠品信息
|
|
|
|
+ * @param colorId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 赠送赠品
|
|
|
|
+ * @param cartDtoList
|
|
|
|
+ */
|
|
|
|
+ private void giftCart(List<CartDto> cartDtoList){
|
|
|
|
+ List<CartDto> giftList = new ArrayList<>();
|
|
|
|
+ SettlementGift settlementGift = new SettlementGift();
|
|
|
|
+ settlementGift.setSettGiftStatus(1);
|
|
|
|
+ List<SettlementGift> settlementGiftList = settlementGiftService.getSettlementGiftList(settlementGift);
|
|
|
|
+ for (CartDto cd:cartDtoList) {
|
|
|
|
+ for (SettlementGift sg:settlementGiftList) {
|
|
|
|
+ if(Objects.equals(cd.getCartColorId(), sg.getSettGiftFillColorId())){
|
|
|
|
+ CartDto cartDto = new CartDto();
|
|
|
|
+ cartDto.setCartColorId(sg.getSettGiftGiftColorId());
|
|
|
|
+ Integer num = sg.getSettGiftNum();
|
|
|
|
+ if(sg.getSettGiftNum() < 1){
|
|
|
|
+ num = cd.getCartNum();
|
|
|
|
+ }
|
|
|
|
+ if(num > sg.getSettGiftMaxNum()){
|
|
|
|
+ num = sg.getSettGiftMaxNum();
|
|
|
|
+ }
|
|
|
|
+ cartDto.setCartNum(num);
|
|
|
|
+ cartDto.setProductDiscount(sg.getSettGiftPrice());
|
|
|
|
+ cartDto.setProductPrice(sg.getSettGiftPrice());
|
|
|
|
+ cartDto.setTotal(sg.getSettGiftPrice()*num);
|
|
|
|
+ giftList.add(cartDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<CartDto> newGiftList = new ArrayList<>();
|
|
|
|
+ if(giftList != null && giftList.size() > 0){
|
|
|
|
+ for (CartDto carD:giftList) {
|
|
|
|
+ boolean fl = false;
|
|
|
|
+ for(CartDto newCarD:newGiftList) {
|
|
|
|
+ if(Objects.equals(newCarD.getCartColorId(), carD.getCartColorId())){
|
|
|
|
+ fl = true;
|
|
|
|
+ Integer oldNum = newCarD.getCartNum();
|
|
|
|
+ newCarD.setCartNum(newCarD.getCartNum() + carD.getCartNum());
|
|
|
|
+ if( newCarD.getCartNum() > newCarD.getColorGiftMaxNum()){
|
|
|
|
+ newCarD.setCartNum(newCarD.getColorGiftMaxNum());
|
|
|
|
+ }
|
|
|
|
+ Integer num = newCarD.getCartNum()+newCarD.getColorSoldNum();
|
|
|
|
+ if(num > newCarD.getColorAllNum()){
|
|
|
|
+
|
|
|
|
+ newCarD.setCartNum(oldNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ newCarD.setProductDiscount(newCarD.getProductDiscount() + carD.getProductDiscount());
|
|
|
|
+ newCarD.setProductPrice( newCarD.getProductPrice() + carD.getProductPrice());
|
|
|
|
+ newCarD.setTotal(newCarD.getTotal() + carD.getTotal());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!fl){
|
|
|
|
+ Product product = productInfoService.selectProductByColorId(carD.getCartColorId());
|
|
|
|
+ carD.setCartId(1);
|
|
|
|
+ carD.setCartProductId(product.getProductId());
|
|
|
|
+ carD.setProductName(product.getProductName());
|
|
|
|
+ carD.setProductType(product.getProductTypeId());
|
|
|
|
+ carD.setProductStatus(1);
|
|
|
|
+ carD.setProductIntroduceImg(product.getColorImg());
|
|
|
|
+ carD.setProductRemark(product.getColorPresent());
|
|
|
|
+ carD.setProductColor(product.getColorName());
|
|
|
|
+ carD.setCartColorId(product.getColorId());
|
|
|
|
+ carD.setProductRemark("");
|
|
|
|
+ carD.setColorAllNum(product.getColorAllNum());
|
|
|
|
+ carD.setColorSoldNum(product.getColorSoldNum());
|
|
|
|
+ carD.setColorToothType(1);
|
|
|
|
+ carD.setProductIntroduceImg(product.getColorImg());
|
|
|
|
+ carD.setColorGiftMaxNum(product.getColorGiftMaxNum());
|
|
|
|
+ if( carD.getCartNum() > carD.getColorGiftMaxNum()){
|
|
|
|
+ carD.setCartNum(carD.getColorGiftMaxNum());
|
|
|
|
+ }
|
|
|
|
+ Integer num = carD.getCartNum()+carD.getColorSoldNum();
|
|
|
|
+ if(num <= carD.getColorAllNum()){
|
|
|
|
+ CartDto newCartDto = new CartDto();
|
|
|
|
+ BeanUtils.copyProperties(carD,newCartDto);
|
|
|
|
+ newGiftList.add(newCartDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!flag){
|
|
+
|
|
- CartDto cd = getGiftCartDtos(id,num);
|
|
+
|
|
- cartDtos.add(cd);
|
|
+ if(newGiftList != null && newGiftList.size() > 0){
|
|
|
|
+ cartDtoList.addAll(newGiftList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- * 获取赠品信息
|
|
+ * 满减
|
|
- * @param colorId
|
|
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private CartDto getGiftCartDtos(Integer colorId,Integer num){
|
|
+ public Integer fullReduc(ActivityDate activityDate, Integer allAmount){
|
|
- CartDto cartDto = new CartDto();
|
|
+ Integer promotionAmout = 0;
|
|
- Product product = productInfoService.selectProductByColorId(colorId);
|
|
+ SalesActivities sa = new SalesActivities();
|
|
- if((product.getColorSoldNum()+1) > product.getColorAllNum()){
|
|
+ sa.setSalesActivitiesStatus(1);
|
|
- return null;
|
|
+ sa.setSalesActivitiesType(activityDate.getType());
|
|
|
|
+ sa.setSalesActivitiesScenes(1);
|
|
|
|
+ List<SalesActivities> salesActivitiesList = salesActivitiesService.getSalesActivitiesList(sa);
|
|
|
|
+ activityDate.setSalesActivitiesList(salesActivitiesList);
|
|
|
|
+ for (SalesActivities salesActivities : salesActivitiesList){
|
|
|
|
+ if(promotionAmout >= salesActivities.getSalesActivitiesFull()){
|
|
|
|
+ promotionAmout = allAmount - salesActivities.getSalesActivitiesReduction();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- cartDto.setCartId(1);
|
|
+ return promotionAmout;
|
|
- cartDto.setCartProductId(product.getProductId());
|
|
|
|
- cartDto.setCartColorId(colorId);
|
|
|
|
- cartDto.setCartNum(num);
|
|
|
|
- cartDto.setProductName(product.getProductName());
|
|
|
|
- cartDto.setProductType(product.getProductTypeId());
|
|
|
|
- cartDto.setProductPrice(product.getColorDiscount());
|
|
|
|
- cartDto.setProductStatus(1);
|
|
|
|
- cartDto.setProductIntroduceImg(product.getColorImg());
|
|
|
|
- cartDto.setTotal(0);
|
|
|
|
- cartDto.setProductDiscount(product.getColorDiscount());
|
|
|
|
- cartDto.setProductRemark(product.getColorPresent());
|
|
|
|
- cartDto.setProductColor(product.getColorName());
|
|
|
|
- cartDto.setColorAllNum(product.getColorAllNum());
|
|
|
|
- cartDto.setColorSoldNum(product.getColorSoldNum());
|
|
|
|
- cartDto.setIsSelfLifting(2);
|
|
|
|
- return cartDto;
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|