mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-04 03:06:39 +08:00
优惠卷
This commit is contained in:
parent
8773b12691
commit
6e46d5743a
@ -15,17 +15,12 @@ public class CouponService {
|
||||
private String url = "http://miniapp-test.royalcanin.com.cn:7080/crm/coupon/";
|
||||
|
||||
public String couponCancel(CouponCancelEntity couponCancelEntity) throws Exception{
|
||||
couponCancelEntity.setChannelId(15);
|
||||
couponCancelEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponCancelEntity);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"cancel",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponCosume(CouponCosumeEntity couponCosumeEntity) throws Exception{
|
||||
couponCosumeEntity.setChannelId(15);
|
||||
couponCosumeEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponCosumeEntity);
|
||||
paramMap.put("petCategoryId",StringUtil.toString(couponCosumeEntity.getPetCategoryId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetCategoryId()));
|
||||
paramMap.put("petBodySizeId",StringUtil.toString(couponCosumeEntity.getPetBodySizeId()).equals("0")?null:StringUtil.toString(couponCosumeEntity.getPetBodySizeId()));
|
||||
@ -34,39 +29,28 @@ public class CouponService {
|
||||
}
|
||||
|
||||
public String couponFetch(CouponFetchEntity couponFetchEntity) throws Exception{
|
||||
couponFetchEntity.setChannelId(15);
|
||||
couponFetchEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponFetchEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"fetch",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponGetAll(CouponGetAllEntity couponGetAllEntity) throws Exception{
|
||||
couponGetAllEntity.setChannelId(15);
|
||||
couponGetAllEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetAllEntity);
|
||||
paramMap.put("status",StringUtil.toString(couponGetAllEntity.getStatus()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getStatus()));
|
||||
paramMap.put("page",StringUtil.toString(couponGetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getPage()));
|
||||
paramMap.put("rows",StringUtil.toString(couponGetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponGetAllEntity.getRows()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"getAll",paramMap,null);
|
||||
}
|
||||
|
||||
public String couponGet(CouponGetEntity couponGetEntity) throws Exception{
|
||||
couponGetEntity.setChannelId(15);
|
||||
couponGetEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponGetEntity);
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"get",paramMap,null);
|
||||
}
|
||||
|
||||
|
||||
public String couponV2GetAll(CouponV2GetAllEntity couponV2GetAllEntity) throws Exception{
|
||||
couponV2GetAllEntity.setChannelId(15);
|
||||
couponV2GetAllEntity.setChannelSecurity("H5@2021");
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(couponV2GetAllEntity);
|
||||
paramMap.put("memberId",StringUtil.toString(couponV2GetAllEntity.getMemberId()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getMemberId()));
|
||||
paramMap.put("activityId",StringUtil.toString(couponV2GetAllEntity.getActivityId()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getActivityId()));
|
||||
@ -74,7 +58,6 @@ public class CouponService {
|
||||
paramMap.put("rows",StringUtil.toString(couponV2GetAllEntity.getRows()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getRows()));
|
||||
paramMap.put("page",StringUtil.toString(couponV2GetAllEntity.getPage()).equals("0")?null:StringUtil.toString(couponV2GetAllEntity.getPage()));
|
||||
MapRemoveNullUtil.removeNullEntry(paramMap);
|
||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(paramMap);
|
||||
return SmartHttpUtil.sendPostForm(url+"v2/getAll",paramMap,null);
|
||||
}
|
||||
}
|
||||
|
@ -13,19 +13,16 @@ public class CouponCancelEntity {
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
/**
|
||||
* 渠道秘钥
|
||||
*/
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 优惠券code
|
||||
*/
|
||||
@ApiModelProperty(example = "0000000336")
|
||||
private String couponCode;
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,12 @@ public class CouponCosumeEntity {
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
/**
|
||||
* 渠道秘钥
|
||||
*/
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 优惠券code
|
||||
|
@ -13,14 +13,12 @@ public class CouponFetchEntity {
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
/**
|
||||
* 渠道秘钥
|
||||
*/
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 会员ID
|
||||
|
@ -12,14 +12,12 @@ public class CouponGetAllEntity {
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
/**
|
||||
* 渠道秘钥
|
||||
*/
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 会员ID
|
||||
|
@ -10,16 +10,13 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CouponGetEntity {
|
||||
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 优惠券编码
|
||||
*/
|
||||
@ApiModelProperty(example = "0000000336")
|
||||
private String couponCode;
|
||||
|
||||
/**
|
||||
|
@ -8,14 +8,12 @@ public class CouponV2GetAllEntity {
|
||||
/**
|
||||
* 渠道
|
||||
*/
|
||||
@ApiModelProperty(example = "2")
|
||||
private int channelId;
|
||||
private String channelId = "15";
|
||||
|
||||
/**
|
||||
* 渠道秘钥
|
||||
*/
|
||||
@ApiModelProperty(example = "H5@2021")
|
||||
private String channelSecurity;
|
||||
private String channelSecurity = "H5@2021";
|
||||
|
||||
/**
|
||||
* 会员ID
|
||||
|
@ -72,6 +72,7 @@ public class OrderController {
|
||||
ordersEntity.setCouponAmount(ordersEntitys.getCouponAmount());
|
||||
ordersEntity.setCouponCode(ordersEntitys.getCouponCode());
|
||||
ordersEntity.setCouponName(ordersEntitys.getCouponName());
|
||||
ordersEntity.setCouponId(ordersEntitys.getCouponId());
|
||||
}
|
||||
orderAddress.setAddressCityName(ordersEntitys.getOrderAddress().getAddressCityName());
|
||||
orderAddress.setAddressCountyName(ordersEntitys.getOrderAddress().getAddressCountyName());
|
||||
@ -81,11 +82,7 @@ public class OrderController {
|
||||
orderAddress.setAddressProvinceName(ordersEntitys.getOrderAddress().getAddressProvinceName());
|
||||
productId.append(ordersEntitys.getProductId()+",");
|
||||
productName.append(ordersEntitys.getProductName()+",");
|
||||
if(ordersEntitys.getPayAmount() != "0"){
|
||||
total_fee = total_fee + (Double.parseDouble(ordersEntitys.getPayAmount()) * ordersEntitys.getBuyCount()) - Double.parseDouble(ordersEntitys.getCouponAmount());
|
||||
}else {
|
||||
total_fee = total_fee + Double.parseDouble(ordersEntitys.getPayAmount())*ordersEntitys.getBuyCount();
|
||||
}
|
||||
total_fee = total_fee + orderService.couponTotal(ordersEntitys.getCouponTypeId(),Double.parseDouble(ordersEntitys.getCouponAmount()),Double.parseDouble(ordersEntitys.getPayAmount()),ordersEntitys.getBuyCount());
|
||||
memberId = ordersEntitys.getMemberId();
|
||||
mobile = ordersEntitys.getPhoneNumber();
|
||||
buyCount = buyCount + ordersEntitys.getBuyCount();
|
||||
|
@ -39,6 +39,5 @@ public class OrderEntity {
|
||||
|
||||
private String payType="1";
|
||||
|
||||
private OrderAddress orderAddress;
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ public class OrdersEntity {
|
||||
|
||||
private Date payTime;
|
||||
|
||||
private String couponTypeId = "0";
|
||||
|
||||
private String couponCode="";
|
||||
|
||||
private String couponAmount="0";
|
||||
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.common.heartbeat.StringUtil;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.CouponService;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCancelEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCosumeEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponFetchEntity;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.couponConfig.CouponConfigFindAllEntity;
|
||||
@ -23,6 +24,7 @@ import net.lab1024.smartadmin.util.MapRemoveNullUtil;
|
||||
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.util.SmartHttpUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import org.apache.poi.hpsf.Decimal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -56,9 +58,9 @@ public class OrderService {
|
||||
BigDecimal realCouponAmount =new BigDecimal(ordersEntity.getOrderAmount());
|
||||
couponCosumeEntity.setRealCouponAmount(realCouponAmount);
|
||||
JSONObject jsonObject = JSONObject.parseObject(couponService.couponCosume(couponCosumeEntity));
|
||||
// if(!jsonObject.getString("code").equals("0")) {
|
||||
// return 0;
|
||||
// }
|
||||
if(!jsonObject.getString("code").equals("0")) {
|
||||
return 0;
|
||||
}
|
||||
//coupon json化
|
||||
OrderCouponEntity orderCouponEntity = new OrderCouponEntity();
|
||||
orderCouponEntity.setCouponCode(ordersEntity.getCouponCode());
|
||||
@ -72,6 +74,7 @@ public class OrderService {
|
||||
|
||||
Map<String, String> paramMap = MapRemoveNullUtil.setConditionMap(ordersEntity);
|
||||
paramMap.remove("orderAddress");
|
||||
paramMap.remove("couponTypeId");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OrderEntity orderEntity = objectMapper.convertValue(paramMap, OrderEntity.class);
|
||||
if(ordersDao.insert(orderEntity) == 1) {
|
||||
@ -117,10 +120,11 @@ public class OrderService {
|
||||
if(ordersEntity != null) {
|
||||
if (!ordersEntity.getCouponCode().equals("") && null != ordersEntity.getCouponCode()) {
|
||||
CouponFetchEntity couponFetchEntity = new CouponFetchEntity();
|
||||
couponFetchEntity.setChannelId(15);
|
||||
couponFetchEntity.setChannelSecurity("H5@2021");
|
||||
couponFetchEntity.setCouponId(ordersEntity.getCouponId());
|
||||
couponFetchEntity.setMemberId(ordersEntity.getMemberId());
|
||||
CouponCancelEntity couponCancelEntity = new CouponCancelEntity();
|
||||
couponCancelEntity.setCouponCode(ordersEntity.getCouponCode());
|
||||
couponService.couponCancel(couponCancelEntity);
|
||||
couponService.couponFetch(couponFetchEntity);
|
||||
}
|
||||
if (ordersDao.cancelOrder(orderNo) == 1) {
|
||||
@ -132,6 +136,12 @@ public class OrderService {
|
||||
addOrSaveEntity.setDeliveryType(jsonObject.getString("deliveryType"));
|
||||
addOrSaveEntity.setSalesAmount(jsonObject.getString("salesAmount"));
|
||||
addOrSaveEntity.setOrderDate(jsonObject.getString("orderDate"));
|
||||
addOrSaveEntity.setAddressUserName(jsonObject.getString("addressUserName"));
|
||||
addOrSaveEntity.setAddressProvinceName(jsonObject.getString("addressProvinceName"));
|
||||
addOrSaveEntity.setAddressPhoneNumber(jsonObject.getString("addressPhoneNumber"));
|
||||
addOrSaveEntity.setAddressDetailInfo(jsonObject.getString("addressDetailInfo"));
|
||||
addOrSaveEntity.setAddressCountyName(jsonObject.getString("addressCountyName"));
|
||||
addOrSaveEntity.setAddressCityName(jsonObject.getString("addressCityName"));
|
||||
addOrSave(addOrSaveEntity);
|
||||
}
|
||||
return ResponseDTO.succ();
|
||||
@ -210,4 +220,27 @@ public class OrderService {
|
||||
royalcaninOperateLogService.add(royalcaninOperateLogEntity);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
public double couponTotal(String couponTypeId,double discount,double total,int buyCount){
|
||||
double endTotal = 0;
|
||||
switch (couponTypeId)
|
||||
{
|
||||
case "5" :
|
||||
endTotal = (total * (buyCount-1)) + (total * discount);
|
||||
break;
|
||||
case "1" :
|
||||
endTotal = total * buyCount - discount;
|
||||
break;
|
||||
case "4" :
|
||||
endTotal = (total * buyCount) * discount;
|
||||
break;
|
||||
case "6" :
|
||||
endTotal = total * buyCount - discount;
|
||||
break;
|
||||
case "0":
|
||||
endTotal = total * buyCount;
|
||||
break;
|
||||
}
|
||||
return endTotal;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user