提交实物代码

dev-discount
袁野 2 years ago
parent 25d02c1fdd
commit c2babeab2f
  1. 39
      hai-bweb/src/main/java/com/bweb/controller/CommonController.java
  2. 20
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  3. 1
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  4. 20
      hai-service/src/main/java/com/hai/entity/HighMerchantStore.java
  5. 23
      hai-service/src/main/java/com/hai/goods/service/GoodsPresentService.java
  6. 28
      hai-service/src/main/java/com/hai/goods/service/impl/GoodsPresentServiceImpl.java
  7. 116
      hai-service/src/main/java/com/hai/model/MapStoreModel.java
  8. 1
      hai-service/src/main/java/com/hai/order/service/impl/OrderCancelHandleServiceImpl.java
  9. 21
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  10. 49
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  11. 7
      hai-service/src/main/java/com/hai/service/CommonService.java
  12. 3
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  13. 4
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  14. 10
      hai-service/src/main/java/com/hai/service/impl/BsOrderRebateServiceImpl.java
  15. 132
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  16. 2
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  17. 79
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  18. 7
      hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java
  19. 5
      hai-service/src/main/resources/dev/commonConfig.properties
  20. 86
      v1/src/main/java/com/v1/controller/business/OrderRebateController.java

@ -1,5 +1,6 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
@ -10,6 +11,7 @@ import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonConfig;
import com.hai.config.TuanYouConfig;
import com.hai.entity.GoodsLogistics;
import com.hai.entity.HighGoodsType;
import com.hai.entity.SecConfig;
import com.hai.entity.SecDictionary;
import com.hai.goods.service.GoodsLogisticsService;
@ -25,10 +27,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@ -423,8 +422,36 @@ public class CommonController {
public ResponseData getIndustry() {
try {
JSONObject object = commonService.getIndustry();
return ResponseMsgUtil.success(object);
JSONArray object = commonService.getIndustry().getJSONArray("return_data");
List<JSONObject> list = new ArrayList<>();
for (Object firstObject : object) {
JSONObject jsonObject = new JSONObject();
JSONObject firstData = (JSONObject) firstObject;
jsonObject.put("title" , firstData.getString("name"));
jsonObject.put("key" , firstData.getLong("id"));
// 判断是否存在子类
if (firstData.getJSONArray("childIndustry").size() > 0) {
List<JSONObject> listChild = new ArrayList<>();
for (Object childObject : firstData.getJSONArray("childIndustry")) {
JSONObject objectChild = new JSONObject();
JSONObject childData = (JSONObject) childObject;
objectChild.put("title" , childData.getString("name"));
objectChild.put("key" , childData.getString("id"));
objectChild.put("isLeaf" , true);
listChild.add(objectChild);
}
jsonObject.put("children" , listChild);
jsonObject.put("selectable" , false);
list.add(jsonObject);
}
}
return ResponseMsgUtil.success(list);
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);

@ -421,4 +421,24 @@ public class CommonController {
}
}
@RequestMapping(value = "/getMapStore", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取地图门店")
public ResponseData getMapStore(
@RequestParam(name = "distance", required = true) Double distance,
@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "childId", required = false) Long childId,
@RequestParam(name = "longitude", required = true) String longitude,
@RequestParam(name = "latitude", required = true) String latitude
) {
try {
return ResponseMsgUtil.success(commonService.getMapStore(name , childId , latitude , longitude , distance));
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -131,5 +131,6 @@ public class CommonSysConfig {
private String logisticsAppSecret;
private String payPostUrl;
private String filesystem;
}

@ -159,6 +159,26 @@ public class HighMerchantStore implements Serializable {
private String ext3;
private Double distance;
private HighMerchant highMerchant;
public Double getDistance() {
return distance;
}
public void setDistance(Double distance) {
this.distance = distance;
}
public HighMerchant getHighMerchant() {
return highMerchant;
}
public void setHighMerchant(HighMerchant highMerchant) {
this.highMerchant = highMerchant;
}
private static final long serialVersionUID = 1L;
public Long getId() {

@ -1,6 +1,7 @@
package com.hai.goods.service;
import com.hai.entity.GoodsPresent;
import com.hai.entity.GoodsPresentRecord;
import java.util.List;
import java.util.Map;
@ -44,6 +45,8 @@ public interface GoodsPresentService {
*/
List<GoodsPresent> getPresentList(Map<String , Object> map);
List<GoodsPresent> getPresentList(Long goodsId);
/**
* @Author Sum1Dream
@ -65,4 +68,24 @@ public interface GoodsPresentService {
*/
void deletePresent(Long id);
/**
* @Author Sum1Dream
* @Name insertPresentRecord
* @Description //TODO
* @Date 14:46 2023/4/27
* @Param [record]
* @Return void
*/
void insertPresentRecord(GoodsPresentRecord record);
/**
* @Author Sum1Dream
* @Name getPresentRecord
* @Description //TODO
* @Date 14:46 2023/4/27
* @Param [map]
* @Return java.util.List<com.hai.entity.GoodsPresentRecord>
*/
List<GoodsPresentRecord> getPresentRecord(Map<String , Object> map);
}

@ -1,8 +1,10 @@
package com.hai.goods.service.impl;
import com.hai.dao.GoodsPresentMapper;
import com.hai.dao.GoodsPresentRecordMapper;
import com.hai.entity.GoodsPresent;
import com.hai.entity.GoodsPresentExample;
import com.hai.entity.GoodsPresentRecord;
import com.hai.entity.GoodsRegionFreight;
import com.hai.goods.service.GoodsPresentService;
import org.apache.commons.collections4.MapUtils;
@ -18,6 +20,9 @@ public class GoodsPresentServiceImpl implements GoodsPresentService {
@Resource
private GoodsPresentMapper goodsPresentMapper;
@Resource
private GoodsPresentRecordMapper goodsPresentRecordMapper;
@Override
public void insertPresent(GoodsPresent present) {
goodsPresentMapper.insert(present);
@ -41,6 +46,19 @@ public class GoodsPresentServiceImpl implements GoodsPresentService {
return goodsPresentMapper.selectByExample(example);
}
@Override
public List<GoodsPresent> getPresentList(Long goodsId) {
GoodsPresentExample example = new GoodsPresentExample();
GoodsPresentExample.Criteria criteria = example.createCriteria();
if (goodsId != null) {
criteria.andGoodsIdEqualTo(goodsId);
}
criteria.andStatusNotEqualTo(String.valueOf(0));
return goodsPresentMapper.selectByExample(example);
}
@Override
public GoodsPresent findPresentById(Long id) {
return goodsPresentMapper.selectByPrimaryKey(id);
@ -50,4 +68,14 @@ public class GoodsPresentServiceImpl implements GoodsPresentService {
public void deletePresent(Long id) {
goodsPresentMapper.deleteByPrimaryKey(id);
}
@Override
public void insertPresentRecord(GoodsPresentRecord record) {
goodsPresentRecordMapper.insert(record);
}
@Override
public List<GoodsPresentRecord> getPresentRecord(Map<String, Object> map) {
return null;
}
}

@ -0,0 +1,116 @@
package com.hai.model;
import com.alibaba.fastjson.JSONObject;
public class MapStoreModel {
private Long id;
private Integer sourceType;
private String logo;
private String latitude;
private String longitude;
private String iconPath;
private Integer rotate;
private Integer width;
private Integer height;
private JSONObject callout;
private double alpha;
private double distance;
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getSourceType() {
return sourceType;
}
public void setSourceType(Integer sourceType) {
this.sourceType = sourceType;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getIconPath() {
return iconPath;
}
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}
public Integer getRotate() {
return rotate;
}
public void setRotate(Integer rotate) {
this.rotate = rotate;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public JSONObject getCallout() {
return callout;
}
public void setCallout(JSONObject callout) {
this.callout = callout;
}
public double getAlpha() {
return alpha;
}
public void setAlpha(double alpha) {
this.alpha = alpha;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
}

@ -56,6 +56,7 @@ public class OrderCancelHandleServiceImpl implements OrderCancelHandleService {
@Override
public void goodsHandle(HighChildOrder childOrder) {
GoodsSku goodsSku = goodsSkuService.findGoodsSkuById(childOrder.getSkuId());
goodsSku.setStock(goodsSku.getStock() + childOrder.getSaleCount());
goodsSkuService.updateGoodsSku(goodsSku);

@ -12,6 +12,7 @@ import com.hai.dao.OutRechargeOrderMapper;
import com.hai.entity.*;
import com.hai.enum_type.*;
import com.hai.goods.service.GoodsDetailService;
import com.hai.goods.service.GoodsPresentService;
import com.hai.goods.service.GoodsSkuService;
import com.hai.goods.service.ShoppingCartService;
import com.hai.model.GasPayPriceModel;
@ -76,6 +77,9 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
@Resource
private HighMerchantStoreService storeService;
@Resource
private GoodsPresentService goodsPresentService;
@Resource
private HighMerchantService merchantService;
@ -948,6 +952,23 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
goodsSkuService.decreaseStockNum(createOrderChild.getSkuId(), createOrderChild.getSaleCount());
List<GoodsPresent> goodsPresents = goodsPresentService.getPresentList(childOrder.getGoodsId());
if (goodsPresents.size() > 0) {
for (GoodsPresent present : goodsPresents) {
GoodsPresentRecord presentRecord = new GoodsPresentRecord();
presentRecord.setStatus("0");
if (present.getType() == 1) {
for (int i = 0; i < present.getNum(); i++) {
couponService.assignOrderStock(present.getSourceId(), childOrder.getChildOrderNo());
}
}
}
}
return childOrder;
}
}

@ -10,6 +10,7 @@ import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.enum_type.*;
import com.hai.goods.service.GoodsOrderExtService;
import com.hai.goods.service.GoodsPresentService;
import com.hai.msg.entity.MsgTopic;
import com.hai.order.service.OrderPaySuccessService;
import com.hai.order.service.OrderService;
@ -73,6 +74,9 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
@Resource
private JinZhuJiaYouService jinZhuJiaYouService;
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private PayloService payloService;
@ -103,6 +107,12 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private GoodsPresentService goodsPresentService;
@Resource
private HighCouponService highCouponService;
@Override
public HighOrder orderPaySuccessHandle(String orderNo, OrderPayType payType, String paySerialNo, BigDecimal payRealPrice, HighUserCard userCard) {
HighOrder order = orderService.getOrderDetailByNo(orderNo);
@ -218,7 +228,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE10.getNumber())) {
thirdOrderHandle(order);
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE11.getNumber())) {
goodsRecharge(order);
goodsRecharge(order , childOrder);
}
}
}
@ -506,11 +516,46 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
* @Param [order]
* @Return void
*/
private void goodsRecharge(HighOrder order) {
private void goodsRecharge(HighOrder order , HighChildOrder highChildOrder) throws Exception {
GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(order.getOrderNo());
goodsOrder.setUpdateTime(new Date());
goodsOrder.setStatus("1");
goodsOrderExtService.updateGoodsOrder(goodsOrder);
List<GoodsPresent> goodsPresents = goodsPresentService.getPresentList(highChildOrder.getGoodsId());
if (goodsPresents.size() > 0) {
for (GoodsPresent present : goodsPresents) {
GoodsPresentRecord presentRecord = new GoodsPresentRecord();
presentRecord.setStatus("0");
if (present.getType() == 1) {
for (int i = 0; i < present.getNum(); i++) {
HighCoupon coupon = highCouponService.getCouponById(present.getSourceId());
// 支付购买卡券
couponCodeService.payCoupon(order,highChildOrder,coupon);
}
}
if (present.getType() == 2) {
highDiscountAgentCodeService.giveDiscount(present.getSourceId() , Long.valueOf(present.getNum()), order.getMemId());
}
presentRecord.setOrderNo(order.getOrderNo());
presentRecord.setOrderId(order.getId());
presentRecord.setChildOrderId(highChildOrder.getOrderId());
presentRecord.setCreateTime(new Date());
presentRecord.setNum(presentRecord.getNum());
presentRecord.setUpdateTime(new Date());
presentRecord.setType(present.getType());
presentRecord.setStatus("1");
presentRecord.setSourceId(present.getSourceId());
presentRecord.setSourceName(present.getSourceName());
presentRecord.setOpName("系统赠送");
presentRecord.setPresentId(present.getId());
goodsPresentService.insertPresentRecord(presentRecord);
}
}
}
}

@ -12,10 +12,7 @@ import com.hai.entity.ApiCity;
import com.hai.entity.SecConfig;
import com.hai.entity.SecDictionary;
import com.hai.entity.SecRegion;
import com.hai.model.IndexCountModel;
import com.hai.model.LineCountModel;
import com.hai.model.OrderCountModel;
import com.hai.model.OrderSumModel;
import com.hai.model.*;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.apache.ibatis.type.BigDecimalTypeHandler;
@ -338,4 +335,6 @@ public interface CommonService {
* @Return com.alibaba.fastjson.JSONObject
*/
JSONObject getIndustry();
List<MapStoreModel> getMapStore(String name , Long childId , String latitude , String longitude , Double distance);
}

@ -163,4 +163,7 @@ public interface HighCouponService {
* @return
*/
int getMonthlySales(Long couponId);
}

@ -92,7 +92,7 @@ public interface HighDiscountAgentCodeService {
*/
Integer getSalesDiscount(Long discountAgentId);
List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId , Long num);
List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId , Long num) throws Exception;
/**
* 优惠券前往使用
@ -100,4 +100,6 @@ public interface HighDiscountAgentCodeService {
* @throws Exception
*/
void useDiscount(Long discountAgentCodeId) throws Exception;
void giveDiscount(Long discountAgentId , Long num , Long userId) throws Exception;
}

@ -123,7 +123,7 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService {
public void insertOrderRebate(JSONObject jsonObject) {
if (jsonObject.getInteger("productType") ==null
|| jsonObject.getLong("userId") == null
|| jsonObject.getString("phone") == null
|| jsonObject.getString("orderNo") == null
|| jsonObject.getLong("orderId") == null
|| jsonObject.getString("title") == null
@ -133,7 +133,7 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "缺少参数!");
}
HighUser highUser = highUserService.findByUserId(jsonObject.getLong("userId"));
HighUser highUser = highUserService.findByPhone(jsonObject.getString("phone"));
// 计算返利积分数量
// 查询是否配置返利
Map<String, Object> map = new HashMap<>();
@ -178,7 +178,7 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService {
}
// 拼接分销返利对象
object.put("userId" , jsonObject.getLong("userId"));
object.put("userId" , highUser.getId());
object.put("orderNo" , jsonObject.getString("orderNo"));
object.put("companyId", 2);
@ -187,7 +187,7 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService {
object.put("logoImg" , OrderProductType.getDataByType(jsonObject.getInteger("productType")).getImgUrl());
bsDistributionUserRelService.distributionRebate(object);
highUserService.goldHandle(jsonObject.getLong("userId"), integralNum.intValue(), 1, jsonObject.getInteger("productType"), jsonObject.getLong("orderId"), object.getString("remark") + integralNum);
highUserService.goldHandle(highUser.getId(), integralNum.intValue(), 1, jsonObject.getInteger("productType"), jsonObject.getLong("orderId"), object.getString("remark") + integralNum);
// 查询积分返利记录
BsOrderRebate orderRebate = new BsOrderRebate();
@ -202,8 +202,6 @@ public class BsOrderRebateServiceImpl implements BsOrderRebateService {
bsOrderRebateMapper.insert(orderRebate);
}
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前未配置积分返利规则!");
}
}
}

@ -8,6 +8,7 @@ import com.google.gson.JsonObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.HttpsUtils;
import com.hai.config.CommonSysConst;
import com.hai.dao.*;
@ -15,6 +16,7 @@ import com.hai.dao.order.OrderStatisticsMapperExt;
import com.hai.entity.*;
import com.hai.model.IndexCountModel;
import com.hai.model.LineCountModel;
import com.hai.model.MapStoreModel;
import com.hai.service.*;
import org.apache.commons.lang3.StringUtils;
@ -27,6 +29,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@Service("iCommonService")
@ -72,6 +75,9 @@ public class CommonServiceImpl implements CommonService {
@Resource
private SecConfigMapper secConfigMapper;
@Resource
private HighMerchantStoreService merchantStoreService;
@ -799,4 +805,130 @@ public class CommonServiceImpl implements CommonService {
public JSONObject getIndustry() {
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getPayPostUrl() + "/common/getIndustry");
}
@Override
public List<MapStoreModel> getMapStore(String name, Long childId , String latitude , String longitude , Double distance) {
// 获取支付门店
Map<String, Object> params = new HashMap<>();
if (name != null) {
params.put("name", name);
}
if (childId != null) {
params.put("childId", childId);
}
List<MapStoreModel> list = new ArrayList<>();
JSONObject payObject = HttpsUtils.doGet(CommonSysConst.getSysConfig().getPayPostUrl() + "/common/getStoreList", params);
if (payObject != null) {
JSONArray payArray = payObject.getJSONArray("return_data");
for (Object object : payArray) {
MapStoreModel storeModel = new MapStoreModel();
JSONObject payData = (JSONObject) object;
storeModel.setId(payData.getLong("id"));
storeModel.setSourceType(1);
storeModel.setLatitude(payData.getString("latitude"));
storeModel.setLongitude(payData.getString("longitude"));
// if (payData.getString("iconPath") == null) {
// storeModel.setLogo(CommonSysConst.getSysConfig().getFilesystem() + "/img/store.png");
// } else {
// storeModel.setLogo(payData.getString("iconPath"));
// }
storeModel.setIconPath(CommonSysConst.getSysConfig().getFilesystem() + "/img/location.png");
storeModel.setLogo(CommonSysConst.getSysConfig().getFilesystem() + "/img/store.png");
storeModel.setRotate(1);
storeModel.setWidth(20);
storeModel.setHeight(20);
storeModel.setAlpha(0.5);
JSONObject callout = new JSONObject();
callout.put("content" , payData.getString("storeName"));
callout.put("address" , payData.getString("address"));
callout.put("color" , "#ffffff");
callout.put("fontSize" , 14);
callout.put("borderRadius" , 15);
callout.put("borderWidth" , "10");
callout.put("bgColor" , "#e51860");
callout.put("display" , "ALWAYS");
storeModel.setCallout(callout);
if (payData.getString("latitude") != null && payData.getString("longitude") != null) {
double distanceS = CoordCommonUtil.getDistance(Double.valueOf(payData.getString("latitude")), Double.valueOf(payData.getString("longitude")), Double.valueOf(latitude), Double.valueOf(longitude));
double storeDistance = Math.round(distanceS/100d)/10d;
if (storeDistance <= distance) {
storeModel.setDistance(storeDistance);
list.add(storeModel);
}
}
}
}
Map<String,Object> map = new HashMap<>();
map.put("storeName", name);
map.put("industryType", childId);
// 获取门店列表
List<HighMerchantStore> merchantStores = merchantStoreService.getMerchantStoreList(map);
if (merchantStores != null) {
for (HighMerchantStore store : merchantStores) {
MapStoreModel storeModel = new MapStoreModel();
storeModel.setId(store.getId());
// 1:支付 2:嗨森逛
storeModel.setSourceType(2);
storeModel.setLatitude(store.getLatitude());
storeModel.setLongitude(store.getLongitude());
storeModel.setIconPath(store.getStoreLogo());
if (store.getStoreLogo() == null) {
storeModel.setLogo(CommonSysConst.getSysConfig().getFilesystem() + "/img/store.png");
} else {
storeModel.setLogo(store.getStoreLogo());
}
storeModel.setIconPath(CommonSysConst.getSysConfig().getFilesystem() + "/img/location.png");
storeModel.setRotate(1);
storeModel.setWidth(20);
storeModel.setHeight(20);
storeModel.setAlpha(0.5);
JSONObject callout = new JSONObject();
callout.put("content" , store.getStoreName());
callout.put("address" , store.getAddress());
callout.put("color" , "#ffffff");
callout.put("fontSize" , 14);
callout.put("borderRadius" , 15);
callout.put("borderWidth" , "10");
callout.put("bgColor" , "#e51860");
callout.put("display" , "ALWAYS");
storeModel.setCallout(callout);
if (store.getLatitude() != null && store.getLongitude() != null) {
double distanceS = CoordCommonUtil.getDistance(Double.valueOf(store.getLatitude()), Double.valueOf(store.getLongitude()), Double.valueOf(latitude), Double.valueOf(longitude));
double storeDistance = Math.round(distanceS/100d)/10d;
if (storeDistance <= distance) {
storeModel.setDistance(storeDistance);
list.add(storeModel);
}
}
}
list = list.stream().sorted(Comparator.comparing(MapStoreModel::getDistance)).collect(Collectors.toList());
}
return list;
}
}

@ -597,4 +597,6 @@ public class HighCouponServiceImpl implements HighCouponService {
public int getMonthlySales(Long couponId) {
return highCouponMapper.getMonthlySales(couponId);
}
}

@ -11,6 +11,7 @@ import com.hai.config.ChongQingCNPCService;
import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighDiscountAgentCodeMapper;
import com.hai.dao.HighDiscountUserRelMapper;
import com.hai.entity.*;
import com.hai.model.DiscountUseConditionModel;
import com.hai.model.HighUserModel;
@ -24,6 +25,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -40,6 +42,9 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
@Resource
private HighDiscountAgentCodeMapper highDiscountAgentCodeMapper;
@Resource
private HighDiscountUserRelMapper highDiscountUserRelMapper;
@Resource
private HighDiscountAgentRelService highDiscountAgentRelService;
@ -178,8 +183,33 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
}
@Override
public List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId, Long num) {
public List<HighDiscountAgentCode> getDiscountAgentCodByLimit(Long discountAgentId, Long num) throws Exception {
String key = "give_discount" + discountAgentId;
try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, discountAgentId);
if(lock) {
List<HighDiscountAgentCode> list = highDiscountAgentCodeMapper.getDiscountAgentCodByLimit(discountAgentId,num);
if (list.size() < num) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存不足!");
}
return highDiscountAgentCodeMapper.getDiscountAgentCodByLimit(discountAgentId,num);
} else {
// 加锁失败,重试
Thread.sleep(100);
getDiscountAgentCodByLimit(discountAgentId , num);
}
}catch (Exception e) {
throw e;
} finally {
// 删除key,释放锁
redisTemplate.delete(key);
}
return null;
}
@Override
@ -272,4 +302,51 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
}
}
@Override
public void giveDiscount(Long discountAgentId, Long num, Long userId) throws Exception {
// 查询可以使用的优惠券
List<HighDiscountAgentCode> discountAgentCodeList = getDiscountAgentCodByLimit(discountAgentId , num);
if (discountAgentCodeList == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存不足!");
}
HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelById(discountAgentId);
HighDiscount discount = highDiscountService.getDiscountById(discountAgentRel.getDiscountId());
// 优惠券
for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList) {
HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel();
highDiscountUserRel.setDiscountId(discountAgentRel.getDiscountId());
highDiscountUserRel.setUserId(userId);
highDiscountUserRel.setAgentId(discountAgentRel.getAgentId());
highDiscountUserRel.setDiscountAgentCodeId(discountAgentCode.getId());
highDiscountUserRel.setStatus(1);
highDiscountUserRel.setCreateTime(new Date());
highDiscountUserRel.setDiscountCompanyId(discount.getCompanyId());
highDiscountUserRel.setDiscountImg(discount.getDiscountImg());
highDiscountUserRel.setDiscountName(discount.getDiscountName());
highDiscountUserRel.setDiscountCondition(discount.getDiscountCondition());
highDiscountUserRel.setDiscountPrice(discount.getDiscountPrice());
// 计算使用有效期
Calendar userEndTime = Calendar.getInstance();
userEndTime.setTime(new Date());
userEndTime.set(Calendar.HOUR_OF_DAY, 23);
userEndTime.set(Calendar.MINUTE, 59);
userEndTime.set(Calendar.SECOND, 59);
userEndTime.add(Calendar.DATE, discount.getEffectiveDay());
highDiscountUserRel.setUseEndTime(userEndTime.getTime());
// 新增优惠券与用户的绑定关系
highDiscountUserRelMapper.insert(highDiscountUserRel);
// 修改优惠券二维码状态
discountAgentCode.setStatus(2);
updateCode(discountAgentCode);
}
}
}

@ -218,6 +218,11 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
criteria.andStoreKeyEqualTo(MapUtils.getString(map, "storeKey"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "industryType"))) {
criteria.andIndustryTypeEqualTo(MapUtils.getInteger(map, "industryType"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "storeName"))) {
criteria.andStoreNameLike("%" + MapUtils.getString(map, "storeName") + "%");
}
@ -234,6 +239,8 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
@Override
public List<HighMerchantStore> getStoreListByLongitude(Map<String, Object> map) {
List<HighMerchantStore> storeList = getMerchantStoreList(map);
for (HighMerchantStore store : storeList) {
double distance = CoordCommonUtil.getDistance(Double.valueOf(store.getLatitude()), Double.valueOf(store.getLongitude()), Double.valueOf(map.get("latitude").toString()), Double.valueOf(map.get("longitude").toString()));

@ -124,5 +124,6 @@ logisticsAppKey=5d806a99fbcc48e19717beef11fa1700
logisticsAppSecret=5ba7552b194e4147b7db1c34143e3317
#PAY
#payPostUrl=https://gratia-pay.dctpay.com/crest/
payPostUrl=http://localhost:9601//crest/
payPostUrl=https://gratia-pay.dctpay.com/crest/
filesystem=https://hsgcs.dctpay.com/filesystem/
#payPostUrl=http://localhost:9601/crest/

@ -6,11 +6,9 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.ApiMerchants;
import com.hai.entity.HighGoldRec;
import com.hai.model.ResponseData;
import com.hai.service.ApiIpAddressService;
import com.hai.service.ApiMerchantsService;
import com.hai.service.BsOrderRebateService;
import com.hai.service.SecConfigService;
import com.hai.service.*;
import com.hai.service.impl.OutRechargeOrderServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +25,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@ -42,9 +41,15 @@ public class OrderRebateController {
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private HighUserService highUserService;
@Resource
private SecConfigService secConfigService;
@Resource
private HighGoldRecService highGoldRecService;
@Resource
private ApiIpAddressService apiIpAddressService;
@ -85,7 +90,7 @@ public class OrderRebateController {
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("userId" , object.getString("userId"));
map.put("phone" , object.getString("phone"));
map.put("productType" , object.getInteger("productType"));
map.put("orderNo" , object.getString("orderNo"));
map.put("orderId" , object.getLong("orderId"));
@ -107,4 +112,75 @@ public class OrderRebateController {
}
}
@RequestMapping(value = "/recycleIntegral", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "退款回收积分")
public ResponseData recycleIntegral(@RequestBody JSONObject object , HttpServletRequest request ) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("merchId")) ||
StringUtils.isBlank(object.getString("orderId")) ||
StringUtils.isBlank(object.getString("orderNo")) ||
StringUtils.isBlank(object.getString("productType")) ||
StringUtils.isBlank(object.getString("sign"))
) {
log.error("getRechargeProduct error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "商户号错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
map.put("productType" , object.getInteger("productType"));
map.put("orderId" , object.getLong("orderId"));
map.put("orderNo" , object.getString("orderNo"));
if (!secConfigService.isSignVerify(map , object.getString("sign"))) {
log.error("getRechargeProduct error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
Map<String, Object> mapGold = new HashMap<>();
mapGold.put("goldType", 1);
mapGold.put("resType", object.getInteger("productType"));
mapGold.put("resId", object.getLong("orderId"));
List<HighGoldRec> goldRecs = highGoldRecService.getGoldRec(mapGold);
for (HighGoldRec goldRec : goldRecs) {
String remark = "订单" + object.getString("orderNo") + "退款,退还积分:" + goldRec.getGold();
// 积分退款
highUserService.goldHandle(goldRec.getUserId(), goldRec.getGold(),1, object.getInteger("productType"), object.getLong("orderId") , remark);
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

Loading…
Cancel
Save