diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java index b4d9072a..ae72ed98 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java @@ -252,7 +252,7 @@ public class HighDiscountPackageController { highDiscountPackage.setCompanyId(highDiscountPackages.getCompanyId()); highDiscountPackage.setCreatedUserId(highDiscountPackages.getCreatedUserId()); highDiscountPackage.setCreatedTime(highDiscountPackages.getCreatedTime()); - highDiscountPackage.setTotalStock(highDiscountPackage.getTotalStock()); + highDiscountPackage.setTotalStock(highDiscountPackages.getTotalStock()); highDiscountPackageService.updateDiscountPackage(highDiscountPackage); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index f4161e99..ed309457 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ -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; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData TCheckEMsgUnionCardVipRights(@RequestParam(name = "phone", required = true) String phone) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone); JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +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; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; // @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取访问令牌backendToken") // public ResponseData getBackendToken() { // try { // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // @RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "请求会员体系") // public ResponseData TCheckEMsgUnionCardVipRights(@RequestParam(name = "phone", required = true) String phone) { // try { // JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone); // JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); // return ResponseMsgUtil.success(cardInfoObject); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // // @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "请求会员体系") // public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { // try { // return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // // @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "解析") // public ResponseData resolveResponse( // @RequestParam(name = "data", required = false) String data // ) { // try { // JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); // return ResponseMsgUtil.success(cardInfoObject); // // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } // // @RequestMapping(value="/getReadFile",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "存入用户信息") // public ResponseData getReadFile() { // try { // highTestService.getReadFile(); // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value="/getUserDiscount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "赠送优惠券") public ResponseData getUserDiscount(@RequestParam(name = "id", required = true) Long id) { try { highTestService.getUserDiscount(id); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/resources/dev/application.yml b/hai-bweb/src/main/resources/dev/application.yml index f799126d..6dbeaaea 100644 --- a/hai-bweb/src/main/resources/dev/application.yml +++ b/hai-bweb/src/main/resources/dev/application.yml @@ -28,11 +28,11 @@ spring: poolPreparedStatements: true maxOpenPreparedStatements: 20 redis: - database: 0 + database: 5 host: 139.159.177.244 port: 36379 password: HF123456.Redis - timeout: 1000 + timeout: 36000000 jedis: pool: max-active: 20 diff --git a/hai-bweb/src/main/resources/pre/application.yml b/hai-bweb/src/main/resources/pre/application.yml index 4c2e5f66..f945f8c0 100644 --- a/hai-bweb/src/main/resources/pre/application.yml +++ b/hai-bweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index f6276a3e..bd90ed5c 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -130,7 +130,6 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/highBrand/*") .excludePathPatterns("/highGoodsType/*") .excludePathPatterns("/sendSms/*") - .excludePathPatterns("/test/*") .excludePathPatterns("/sms/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index 26c25e49..a8945cfa 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -55,7 +55,7 @@ public class CmsContentController { map.put("companyId", bsCompany.getId().toString()); map.put("status", "2"); map.put("categoryCode", categoryCode); - return ResponseMsgUtil.success(cmsContentService.getListContent(map)); + return ResponseMsgUtil.success(cmsContentService.getListContentByCrest(map)); } } return ResponseMsgUtil.success(new ArrayList<>()); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index ddee2d97..faebbc10 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -53,9 +53,6 @@ public class HighCouponController { @Resource private HighCouponCodeService highCouponCodeService; - @Resource - private HighOrderService highOrderService; - @Resource private HighUserCouponService highUserCouponService; diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 3028651a..7e469d5d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -122,15 +122,16 @@ public class OutRechargeOrderController { // 支付类型 1.微信支付 outRechargeOrder.setPayType(1); // 判断充值模式:1 电信 2. 移动 3. 联通 - JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); - if (telObject.get("status").equals(0)) { - JSONObject o = telObject.getObject("result",JSONObject.class); - // 拼接内容 - remarks = o.get("province").toString() + o.get("company").toString() + "充值" + outRechargeOrder.getOrderPrice() + "元"; - } else { - log.error("orderToPay error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); - } + // 拼接内容 + remarks = outRechargeOrder.getRechargeContent() + "充值" + outRechargeOrder.getOrderPrice() + "元"; +// JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); +// if (telObject.get("status").equals(0)) { +// JSONObject o = telObject.getObject("result",JSONObject.class); +// +// } else { +// log.error("orderToPay error!"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); +// } HighDiscountUserRel highDiscountUserRel = null; if (outRechargeOrder.getMemDiscountId() != null) { diff --git a/hai-cweb/src/main/resources/pre/application.yml b/hai-cweb/src/main/resources/pre/application.yml index 1012ea5c..f425a243 100644 --- a/hai-cweb/src/main/resources/pre/application.yml +++ b/hai-cweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/test/common/test.java b/hai-cweb/src/test/common/test.java index d88c1ee4..41a01fe1 100644 --- a/hai-cweb/src/test/common/test.java +++ b/hai-cweb/src/test/common/test.java @@ -46,7 +46,7 @@ public class test { @Test public void test(){ -/* List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); + List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); List userList = highUserService.getUserList(); @@ -55,7 +55,7 @@ public class test { // 领取优惠券 highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); num++; - }*/ + } } diff --git a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java index 1e78cfbd..443f9ff3 100644 --- a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java @@ -44,7 +44,7 @@ public interface CmsContentMapperExt { " AND cc.status = #{status}", " ", "", - "ORDER BY cc.category_code", + "ORDER BY cc.category_code and cc.sort_id", "" }) @Results({ @@ -76,4 +76,67 @@ public interface CmsContentMapperExt { }) List getListContent(Map paramsMap) throws Exception; + + @Select(value = { + "" + }) + @Results({ + @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), + @Result(column="title", property="title", jdbcType= JdbcType.VARCHAR), + @Result(column="category_id", property="categoryId", jdbcType= JdbcType.BIGINT), + @Result(column="category_code", property="categoryCode", jdbcType= JdbcType.VARCHAR), + @Result(column="description", property="description", jdbcType= JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType= JdbcType.INTEGER), + @Result(column="has_patch", property="hasPatch", jdbcType= JdbcType.TINYINT), + @Result(column="visit_count", property="visitCount", jdbcType= JdbcType.INTEGER), + @Result(column="tag", property="tag", jdbcType= JdbcType.VARCHAR), + @Result(column="img_source", property="imgSource", jdbcType= JdbcType.TINYINT), + @Result(column="img_data", property="imgData", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_type", property="jumpType", jdbcType= JdbcType.INTEGER), + @Result(column="jump_name", property="jumpName", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_url", property="jumpUrl", jdbcType= JdbcType.VARCHAR), + @Result(column="sort_id", property="sortId", jdbcType= JdbcType.INTEGER), + @Result(column="update_time", property="updateTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="recommend", property="recommend", jdbcType= JdbcType.BIT), + @Result(column="company_id", property="companyId", jdbcType= JdbcType.BIGINT), + @Result(column="op_id", property="opId", jdbcType= JdbcType.BIGINT), + @Result(column="ext_1", property="ext1", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType= JdbcType.VARCHAR), + @Result(column="content", property="content", jdbcType= JdbcType.LONGVARCHAR), + @Result(column="category_name", property="categoryName", jdbcType= JdbcType.VARCHAR), + }) + List getListContentByCrest(Map paramsMap) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/service/CmsContentService.java b/hai-service/src/main/java/com/hai/service/CmsContentService.java index 47a64f8d..2f7e7c43 100644 --- a/hai-service/src/main/java/com/hai/service/CmsContentService.java +++ b/hai-service/src/main/java/com/hai/service/CmsContentService.java @@ -85,6 +85,19 @@ public interface CmsContentService { */ List getListContent(Map paramsMap) throws Exception; + + /** + * + * @Title: getListContent + * @Description: 查询内容列表 + * @author: gongjia + * @param: [paramsMap] + * @return: java.util.List + * @throws + */ + List getListContentByCrest(Map paramsMap) throws Exception; + + /** * * @Title: getCorporateAdvertising diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java index 7fe0e5c5..e22d3382 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java @@ -89,4 +89,14 @@ public interface HighDiscountPackageService { */ void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num); + /** + * @Author Sum1Dream + * @name freeUserDiscountPackage.java + * @Description // 赠送用户优惠券包内容 + * @Date 3:09 下午 2021/12/24 + * @Param [java.lang.Long] + * @return void + */ + void freeUserDiscountPackage(Map map) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountService.java b/hai-service/src/main/java/com/hai/service/HighDiscountService.java index 7f60ae30..8661c42b 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountService.java @@ -39,5 +39,6 @@ public interface HighDiscountService { * @Date 2021/4/3 21:39 **/ List getDiscount(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/HighTestService.java b/hai-service/src/main/java/com/hai/service/HighTestService.java new file mode 100644 index 00000000..c1ae0656 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighTestService.java @@ -0,0 +1,33 @@ +package com.hai.service; + +/** + * @serviceName HltMerchantService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 测试接口 + * @createTime 11:46 上午 2021/12/15 + **/ +public interface HighTestService { + + /** + * @Author Sum1Dream + * @name getReadFile.java + * @Description //读取文件 + * @Date 5:31 下午 2021/12/16 + * @Param [] + * @return void + */ + void getReadFile() throws Exception; + + + /** + * @Author Sum1Dream + * @name getUserDiscount.java + * @Description // 赠送用户卡券 + * @Date 7:14 下午 2021/12/24 + * @Param [] + * @return void + */ + void getUserDiscount(Long id) throws Exception; + +} diff --git a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java index f7a883eb..2dac374a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java @@ -178,6 +178,11 @@ public class CmsContentServiceImpl implements CmsContentService { return cmsContentMapper.getListContent(paramsMap); } + @Override + public List getListContentByCrest(Map paramsMap) throws Exception { + return cmsContentMapper.getListContentByCrest(paramsMap); + } + @Override public List getCorporateAdvertising() { CmsContentExample example = new CmsContentExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java index bb336378..5a0f38e6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java @@ -3,12 +3,16 @@ package com.hai.service.impl; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.IDGenerator; +import com.hai.common.utils.RedisUtil; import com.hai.dao.*; import com.hai.entity.*; import com.hai.model.UserInfoModel; import com.hai.service.*; import com.hai.service.HighDiscountPackageService; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -52,6 +56,28 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Resource private HighDiscountInventoryRecordMapper discountInventoryRecordMapper; + @Resource + private HighUserService highUserService; + + @Resource + private HighDiscountPackageService highDiscountPackageService; + + + @Resource + private HighDiscountUserRelMapper highDiscountUserRelMapper; + + @Resource + private HighDiscountService highDiscountService; + + @Resource + private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; + + @Autowired + private RedisUtil redisUtil; + @Override public List getDiscountPackageList(Map map) { @@ -223,4 +249,75 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic highDiscountPackageMapper.updateByPrimaryKey(highDiscountPackage); } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void freeUserDiscountPackage(Map map) throws Exception { + + + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); + + + // 查询优惠券包实际库存 + HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0); + + // 修改优惠券包实际库存为已使用 + discountPackageActual.setStatus(0); + discountPackageActual.setUserId(MapUtils.getInteger(map , "userId")); + discountPackageActual.setAllocationTime(new Date()); + discountPackageActualService.updateHighDiscountPackageActual(discountPackageActual); + + // 查询优惠券包实际库存中实际优惠券数量 + List discountPackageDiscountActual = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(discountPackageActual.getId()); + + // 循环赠送优惠券 + for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { + + HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); + highDiscountUserRel.setDiscountId(actualList.getDiscountId()); + highDiscountUserRel.setUserId(MapUtils.getLong(map , "userId")); + highDiscountUserRel.setAgentId(actualList.getAgentId()); + highDiscountUserRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId()); + highDiscountUserRel.setStatus(1); + highDiscountUserRel.setCreateTime(new Date()); + + HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.getDiscountId()); + + // 计算使用有效期 + 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, highDiscount.getEffectiveDay()); + highDiscountUserRel.setUseEndTime(userEndTime.getTime()); + + HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); + + // 修改优惠券二维码状态 + discountAgentCode.setStatus(2); + highDiscountAgentCodeService.updateCode(discountAgentCode); + + // 新增优惠券与用户的绑定关系 + highDiscountUserRelMapper.insert(highDiscountUserRel); + + // 修改优惠券包实际库存实际优惠券状态 + actualList.setStatus(0); + discountPackageDiscountActualService.updateHighDiscountPackageDiscountActual(actualList); + } + + // 增加赠送记录 + HighDiscountPackageRecord discountPackageRecord = new HighDiscountPackageRecord(); + discountPackageRecord.setDiscountPackageId(highDiscountPackage.getId()); + discountPackageRecord.setDiscountPackageTitle(highDiscountPackage.getTitle()); + discountPackageRecord.setCompanyId(highDiscountPackage.getCompanyId()); + discountPackageRecord.setStatus(1); + discountPackageRecord.setUsingAttribution(1); + discountPackageRecord.setRecordNo("DP" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5) ); + discountPackageRecord.setSalesType(2); + discountPackageRecord.setUserId(MapUtils.getInteger(map , "userId")); + discountPackageRecord.setExt1(MapUtils.getString(map , "userPhone")); + discountPackageRecord.setCreatedTime(new Date()); + highDiscountPackageRecordMapper.insert(discountPackageRecord); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java new file mode 100644 index 00000000..c2d2d96b --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java @@ -0,0 +1,136 @@ +package com.hai.service.impl; + + +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.RedisUtil; +import com.hai.dao.HighUserEtcMapper; +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighUser; +import com.hai.entity.HighUserEtc; +import com.hai.service.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service("highTestService") +public class HighTestServiceImpl implements HighTestService { + + private static Logger log = LoggerFactory.getLogger(HighTestService.class); + + @Resource + private HighUserService highUserService; + + @Resource + private HighUserEtcMapper highUserEtcMapper; + + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Autowired + private RedisUtil redisUtil; + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getReadFile() throws Exception { +// BufferedReader bufferedReader = null; +// +// Map mapUser = new HashMap<>(); +// +// //cookie过期时间为7天 +// int EXPIRE = 3600*24*7; +// +// List highUsers = highUserService.getListUser(mapUser); +// +// for (HighUser user: highUsers) { +// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE); +// } +// +// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt"); +// if (fileReader == null) { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据"); +// } +// +// bufferedReader = new BufferedReader(fileReader); +// String temp = bufferedReader.readLine(); +// int i = 0; +// while (temp != null) { +// i++; +// String[] arr = temp.split(";"); +// +// String phone = (String) redisUtil.get(arr[3]); +// +// if (phone == null || highUsers.size() == 0) { +// HighUser user = new HighUser(); +// +// user.setStatus(1); +// user.setInfoCompleteStatus(1); +// user.setGold(0); +// user.setRegTime(new Date()); +// user.setName(arr[2]); +// user.setPhone(arr[3]); +// user.setExt4("1"); +// +// highUserService.insertUser(user); +// +// HighUserEtc userEtc = new HighUserEtc(); +// +// userEtc.setCreateTime(new Date()); +// userEtc.setStatus(1); +// userEtc.setUserId(user.getId()); +// userEtc.setCustomerName(arr[2]); +// userEtc.setCustomerTel(arr[3]); +// userEtc.setVehicleId(arr[0]); +// userEtc.setVehiclePlate(arr[1]); +// +// highUserEtcMapper.insert(userEtc); +// +//// Map map = new HashMap<>(); +//// map.put("userId" , user.getId()); +//// map.put("userPhone" , user.getPhone()); +//// map.put("discountPackageId" , 48); +// +//// highDiscountPackageService.freeUserDiscountPackage(map); +// } +// +// temp = bufferedReader.readLine(); +// } + } + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getUserDiscount(Long id) throws Exception{ + List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1); + Map map = new HashMap<>(); + map.put("ext4" , "1"); + List userList = highUserService.getListUser(map); + + int num = 0; + for (HighUser user : userList) { + // 领取优惠券 + highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); + num++; + } + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index cb7ff1c5..a50755da 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -65,6 +65,9 @@ public class HighUserServiceImpl implements HighUserService { if (StringUtils.isNotBlank(map.get("status"))) { criteria.andStatusEqualTo(Integer.valueOf(map.get("status"))); } + if (StringUtils.isNotBlank(map.get("ext4"))) { + criteria.andExt4EqualTo(String.valueOf(map.get("ext4"))); + } if (StringUtils.isNotBlank(map.get("regTimeStart")) && StringUtils.isNotBlank(map.get("regTimeEnd"))) { criteria.andRegTimeBetween( DateUtil.format(map.get("regTimeStart") , "yyyy-MM-dd HH:mm:ss") , diff --git a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java index 872eecba..735e832b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java @@ -116,8 +116,6 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService { HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0); - highDiscountPackageService.updateDiscountPackage(highDiscountPackage); - // 查询优惠券包实际库存 HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0);