Merge branch 'cpupon-dev' of http://gitea.dctpay.com/hurui/puhui-go into cpupon-dev
commit
e4c7af56fb
@ -0,0 +1,130 @@ |
||||
package com.bweb.controller.goods; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.CouponDiscountPackage; |
||||
import com.hfkj.entity.GoodPresent; |
||||
import com.hfkj.entity.GoodsMsg; |
||||
import com.hfkj.entity.GoodsType; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.discount.CouponDiscountPackageService; |
||||
import com.hfkj.service.goods.GoodPresentService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/goodPresent") |
||||
@Api(value="商品赠送") |
||||
public class GoodPresentController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GoodPresentController.class); |
||||
|
||||
@Resource |
||||
private GoodPresentService goodPresentService; |
||||
|
||||
@Resource |
||||
private CouponDiscountPackageService discountPackageService; |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value="/createGoodPresent",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "创建商品赠送") |
||||
public ResponseData createGoodPresent(@RequestBody GoodPresent body, HttpServletRequest request) { |
||||
|
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
if (!userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
|
||||
if (body == null |
||||
|| body.getKey() == null |
||||
|| body.getType() == null |
||||
|| body.getSpecsId() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
CouponDiscountPackage discountPackage = discountPackageService.findDiscountPackageByKey(body.getKey()); |
||||
if (discountPackage == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券包不存在"); |
||||
} |
||||
|
||||
body.setCreateTime(new Date()); |
||||
body.setUpdateTime(new Date()); |
||||
body.setStatus(1); |
||||
body.setName(discountPackage.getTitle()); |
||||
goodPresentService.create(body); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
@RequestMapping(value="/getListBrand",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询列表") |
||||
public ResponseData getListBrand(@RequestParam(value = "specsId" , required = false) Long specsId) { |
||||
try { |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("specsId", specsId); |
||||
return ResponseMsgUtil.success(goodPresentService.getList(map)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/delete",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除") |
||||
public ResponseData delete(@RequestParam(value = "id" , required = false) Long id, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||
|
||||
if (!userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
|
||||
goodPresentService.delete(id , false); |
||||
|
||||
return ResponseMsgUtil.success("删除成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,101 @@ |
||||
package com.cweb.controller.output; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.api.ApiMerService; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.common.utils.SignatureUtil; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.UserSessionObject; |
||||
import com.hfkj.service.SecDictionaryService; |
||||
import com.hfkj.service.discount.CouponDiscountPackageService; |
||||
import com.hfkj.service.discount.CouponDiscountService; |
||||
import com.hfkj.service.discount.CouponDiscountUserRelService; |
||||
import com.hfkj.service.user.BsUserService; |
||||
import com.hfkj.sysenum.UserLoginPlatform; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.*; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
import java.util.function.Function; |
||||
import java.util.function.Predicate; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/output") |
||||
@Api(value="输出外部接口") |
||||
public class OutputController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OutputController.class); |
||||
|
||||
@Resource |
||||
private ApiMerService apiMerService; |
||||
|
||||
@Resource |
||||
private CouponDiscountUserRelService discountUserRelService; |
||||
@Resource |
||||
private BsUserService bsUserService; |
||||
|
||||
@RequestMapping(value = "/getListUserDiscount", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取用户优惠券列表") |
||||
public ResponseData getListUserDiscount(@RequestBody JSONObject body) { |
||||
try { |
||||
|
||||
if (body == null |
||||
|| StringUtils.isBlank(body.getString("status")) |
||||
|| StringUtils.isBlank(body.getString("phone")) |
||||
|| StringUtils.isBlank(body.getString("sign")) |
||||
|| StringUtils.isBlank(body.getString("appid")) |
||||
) { |
||||
log.error("LoginController --> phone() error!", "请求参数校验失败"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询api商户信息
|
||||
ApiMer apiMer = apiMerService.queryDetail(body.getString("appid")); |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("appid" , body.getString("appid")); |
||||
map.put("phone" , body.getString("phone")); |
||||
map.put("status" , body.getString("status")); |
||||
String sign = SignatureUtil.createSign(map , apiMer.getAppSecret()); |
||||
if (!body.getString("sign").equals(sign)) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!"); |
||||
} |
||||
|
||||
// 查询用户信息
|
||||
BsUser user = bsUserService.getUser(body.getString("phone")); |
||||
|
||||
if (user == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户不存在!"); |
||||
} |
||||
|
||||
Map<String, Object> mapPost = new HashMap<>(); |
||||
|
||||
mapPost.put("userId", user.getId()); |
||||
mapPost.put("status", body.getInteger("status")); |
||||
|
||||
return ResponseMsgUtil.success(discountUserRelService.getList(mapPost)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("GoodsDetailController --> getListUser() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.hfkj.model.discount; |
||||
|
||||
import com.hfkj.entity.CouponDiscountUserRel; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class CouponDiscountUserRelModel extends CouponDiscountUserRel { |
||||
|
||||
/** |
||||
* 优惠券来源 |
||||
*/ |
||||
private Integer source; |
||||
|
||||
/** |
||||
* 优惠券编号 |
||||
*/ |
||||
private String discountNo; |
||||
|
||||
} |
@ -0,0 +1,59 @@ |
||||
package com.hfkj.service.goods; |
||||
|
||||
|
||||
import com.hfkj.entity.GoodPresent; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface GoodPresentService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name create |
||||
* @Description // 创建
|
||||
* @Date 15:12 2024/4/19 |
||||
* @Param GoodsBrand |
||||
* @return void |
||||
*/ |
||||
void create(GoodPresent goodPresent); |
||||
|
||||
/** |
||||
* @MethodName update |
||||
* @Description: 更新 |
||||
* @param goodPresent |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/18 下午3:39 |
||||
*/ |
||||
void update(GoodPresent goodPresent); |
||||
|
||||
/** |
||||
* @MethodName findById |
||||
* @Description: |
||||
* @param id |
||||
* @return: com.hfkj.entity.GoodPresent |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/18 下午3:38 |
||||
*/ |
||||
GoodPresent findById(Long id); |
||||
|
||||
/** |
||||
* @MethodName getList |
||||
* @Description: 查询列表 |
||||
* @param map |
||||
* @return: java.util.List<com.hfkj.entity.GoodPresent> |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/18 下午3:39 |
||||
*/ |
||||
List<GoodPresent> getList(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @MethodName delete |
||||
* @Description: 删除 |
||||
* @param id |
||||
* @param fullDelete |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/12/18 下午3:42 |
||||
*/ |
||||
void delete(Long id , Boolean fullDelete); |
||||
} |
@ -0,0 +1,62 @@ |
||||
package com.hfkj.service.goods.impl; |
||||
|
||||
import com.hfkj.dao.GoodPresentMapper; |
||||
import com.hfkj.entity.GoodPresent; |
||||
import com.hfkj.entity.GoodPresentExample; |
||||
import com.hfkj.entity.GoodsBrand; |
||||
import com.hfkj.service.goods.GoodPresentService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("goodPresentService") |
||||
public class GoodPresentServiceImpl implements GoodPresentService { |
||||
|
||||
@Resource |
||||
private GoodPresentMapper goodPresentMapper; |
||||
|
||||
@Override |
||||
public void create(GoodPresent goodPresent) { |
||||
goodPresentMapper.insert(goodPresent); |
||||
} |
||||
|
||||
@Override |
||||
public void update(GoodPresent goodPresent) { |
||||
goodPresentMapper.updateByPrimaryKey(goodPresent); |
||||
} |
||||
|
||||
@Override |
||||
public GoodPresent findById(Long id) { |
||||
return goodPresentMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<GoodPresent> getList(Map<String, Object> map) { |
||||
GoodPresentExample example = new GoodPresentExample(); |
||||
GoodPresentExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getLong(map, "specsId") != null) { |
||||
criteria.andSpecsIdEqualTo(MapUtils.getLong(map, "specsId")); |
||||
} |
||||
|
||||
return goodPresentMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public void delete(Long id, Boolean fullDelete) { |
||||
if (fullDelete) { |
||||
goodPresentMapper.deleteByPrimaryKey(id); |
||||
} else { |
||||
GoodPresent goodPresent = findById(id); |
||||
goodPresent.setStatus(0); |
||||
goodPresent.setUpdateTime(new Date()); |
||||
update(goodPresent); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue