| | |
| | | package com.yeshi.fanli.controller.admin.shop;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.multipart.MultipartHttpServletRequest;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | |
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsClass;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | |
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, BanLiShopGoods record, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | String picture = null;
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | MultipartFile file = fileRequest.getFile("file");
|
| | | if (file != null)
|
| | | picture = uploadPicture(file);
|
| | | banLiShopGoodsService.saveObject(fileRequest.getFile("file"),fileRequest.getFile("file2"), record);
|
| | | } else {
|
| | | banLiShopGoodsService.saveObject(null, null,record);
|
| | | }
|
| | | record.setPicture(picture);
|
| | | banLiShopGoodsService.addGoods(record);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BanLiShopGoodsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (BanLiShopGoodsSetException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (BanLiShopGoodsSetPayException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * |
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String uploadPicture(MultipartFile file) throws BanLiShopGoodsException {
|
| | | // 文件解析
|
| | | InputStream inputStream;
|
| | | try {
|
| | | inputStream = file.getInputStream();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | throw new BanLiShopGoodsException(1, "图片获取失败");
|
| | | }
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 文件路径
|
| | | String filePath = "/img/HomeNavbar/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 查询
|
| | |
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsSets;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, BanLiShopGoodsSets record, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | banLiShopGoodsSetService.addSet(record);
|
| | | banLiShopGoodsSetService.saveObject(record);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BanLiShopGoodsSetException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (BanLiShopGoodsSetPayException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | | @RequestMapping(value = "save")
|
| | | public void save(String callback, BanLiShopGoodsSetsPay record, HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | banLiShopGoodsSetPayService.addSetPay(record);
|
| | | banLiShopGoodsSetPayService.saveObject(record);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (BanLiShopGoodsSetPayException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | package com.yeshi.fanli.service.impl.money;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.user.UserMoneyExtraMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
|
| | | @Service
|
| | | public class UserMoneyExtraServiceImpl implements UserMoneyExtraService {
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void listValid(int page, int count) {
|
| | | userMoneyExtraMapper.listValid((page-1) * count, count);
|
| | | public List<UserMoneyExtra> listValid(int page, int count) {
|
| | | return userMoneyExtraMapper.listValid((page-1) * count, count);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.shop;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.shop.BanLiShopGoodsMapper;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | |
| | |
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void saveObject(MultipartFile file, MultipartFile file2, BanLiShopGoods record) throws BanLiShopGoodsException, Exception{
|
| | | if (record.getGoodsClass() == null || record.getGoodsClass().getId() == null)
|
| | | throw new BanLiShopGoodsException(1, "请指定商品分类");
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(record.getTitle()))
|
| | | throw new BanLiShopGoodsException(1, "缺少标题");
|
| | |
|
| | | if (file != null)
|
| | | record.setPicture(uploadPicture(file));
|
| | | |
| | | if (file2 != null)
|
| | | record.setSquarePicture(uploadPicture(file2));
|
| | | |
| | | if (record.getState() == null)
|
| | | record.setState(BanLiShopGoods.STATE_ONLINE);
|
| | | |
| | | if (record.getSalesCount() == null)
|
| | | record.setSalesCount(0L);
|
| | | |
| | | record.setUpdateTime(new Date());
|
| | | |
| | | if (record.getId() == null) {
|
| | | if (StringUtil.isNullOrEmpty(record.getPicture()))
|
| | | throw new BanLiShopGoodsException(1, "缺少封面图");
|
| | | |
| | | record.setCreateTime(new Date());
|
| | | banLiShopGoodsMapper.insertSelective(record);
|
| | | } else {
|
| | | BanLiShopGoods resultObj = banLiShopGoodsMapper.selectDetailByPrimaryKey(record.getId());
|
| | | if (resultObj == null)
|
| | | throw new BanLiShopGoodsException(1, "修改内容已不存在");
|
| | | |
| | | if (StringUtil.isNullOrEmpty(record.getPicture())) {
|
| | | record.setPicture(resultObj.getPicture());
|
| | | } else {
|
| | | removePicture(resultObj.getPicture());
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(record.getSquarePicture())) {
|
| | | record.setSquarePicture(resultObj.getSquarePicture());
|
| | | } else {
|
| | | removePicture(resultObj.getSquarePicture());
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(record.getPicture()))
|
| | | throw new BanLiShopGoodsException(1, "缺少封面图");
|
| | | |
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | banLiShopGoodsMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String uploadPicture(MultipartFile file) throws Exception {
|
| | | // 文件解析 |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 文件路径
|
| | | String filePath="/img/BanLiShopGoods/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | return fileLink;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除图片-不更新数据库
|
| | | * @param record
|
| | | * @throws Exception
|
| | | */
|
| | | public void removePicture(String picture) throws Exception {
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public void updateSelectiveByPrimaryKey(BanLiShopGoods goods) {
|
| | | if (goods == null || goods.getId() == null)
|
| | |
| | | updateSelectiveByPrimaryKey(pay);
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public void saveObject(BanLiShopGoodsSetsPay record) throws BanLiShopGoodsSetPayException {
|
| | | // 判断参数是否齐全
|
| | | if (record.getGoodsSet() == null || record.getGoodsSet().getId() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "套餐不存在");
|
| | |
|
| | | if (record.getPayType() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "请指定支付方式");
|
| | |
|
| | | if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO) {
|
| | | if (record.getHongBaoPrice() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "请指定红包支付价格");
|
| | | } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_BALANCE) {
|
| | | if (record.getBalancePrice() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "请指定余额支付价格");
|
| | | } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO_MONEY) {
|
| | | if (record.getHongBaoPrice() == null || record.getMoneyPrice() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "请指定红包、现金支付价格");
|
| | | } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_MONEY) {
|
| | | if (record.getMoneyPrice() == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "请指定现金支付价格");
|
| | | }
|
| | |
|
| | | record.setUpdateTime(new Date());
|
| | | if (record.getId() == null) {
|
| | | record.setCreateTime(new Date());
|
| | | banLiShopGoodsSetsPayMapper.insertSelective(record);
|
| | |
|
| | | if (record.getWeight() == null) {// 权重更新
|
| | | BanLiShopGoodsSetsPay update = new BanLiShopGoodsSetsPay();
|
| | | update.setId(record.getId());
|
| | | update.setWeight((int) record.getId().longValue());
|
| | | banLiShopGoodsSetsPayMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | } else {
|
| | | BanLiShopGoodsSetsPay resultObj = banLiShopGoodsSetsPayMapper.selectByPrimaryKey(record.getId());
|
| | | if (resultObj == null)
|
| | | throw new BanLiShopGoodsSetPayException(1, "修改内容已不存在");
|
| | | |
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | banLiShopGoodsSetsPayMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateSelectiveByPrimaryKey(BanLiShopGoodsSetsPay pay) {
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void saveObject(BanLiShopGoodsSets record) throws BanLiShopGoodsSetException {
|
| | | if (record.getGoods() == null || record.getGoods().getId() == null)
|
| | | throw new BanLiShopGoodsSetException(1, "请指定商品");
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(record.getName()))
|
| | | throw new BanLiShopGoodsSetException(1, "缺少套餐名字");
|
| | |
|
| | | if (record.getOriginalPrice() == null || record.getZkPrice() == null)
|
| | | throw new BanLiShopGoodsSetException(1, "价格信息不完整");
|
| | |
|
| | | if (record.getStock() == null)
|
| | | throw new BanLiShopGoodsSetException(1, "缺少库存信息");
|
| | |
|
| | | record.setUpdateTime(new Date());
|
| | | if (record.getId() == null) {
|
| | | record.setCreateTime(new Date());
|
| | | banLiShopGoodsSetsMapper.insertSelective(record);
|
| | | |
| | | if (record.getWeight() == null) {// 权重更新
|
| | | BanLiShopGoodsSets update = new BanLiShopGoodsSets();
|
| | | update.setId(record.getId());
|
| | | update.setWeight((int) record.getId().longValue());
|
| | | banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | } else {
|
| | | BanLiShopGoodsSets resultObj = banLiShopGoodsSetsMapper.selectDetailByPrimaryKey(record.getId());
|
| | | if (resultObj == null)
|
| | | throw new BanLiShopGoodsSetException(1, "修改内容已不存在");
|
| | | |
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | banLiShopGoodsSetsMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | @Override
|
| | | public void updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) {
|
| | |
| | | MsgOtherRewardIntegralDTO msgOther = new MsgOtherRewardIntegralDTO();
|
| | | msgOther.setTitle("推广红包");
|
| | | msgOther.setTotal("推广红包¥" + tlj.setScale(2));
|
| | | msgOther.setNum(goldCoin + "枚");
|
| | | msgOther.setNum(addGoldCoin + "枚");
|
| | | msgOther.setSource("已进入到可用金币中");
|
| | | msgOther.setExplain("原推广红包功能下线,剩余推广红包按照10:1折算为金币 ");
|
| | | userOtherMsgNotificationService.taoLiJinExchangeMsg(uid, "本折算有且仅有一次", msgOther);
|
| | |
| | | package com.yeshi.fanli.service.inter.money;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
|
| | |
|
| | | public interface UserMoneyExtraService {
|
| | |
| | | public void updateByPrimaryKeySelective(UserMoneyExtra record);
|
| | |
|
| | |
|
| | | public void listValid(int page, int count);
|
| | | /**
|
| | | * 获取有效金币用户
|
| | | * @param page
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<UserMoneyExtra> listValid(int page, int count);
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoods;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException;
|
| | |
| | | */
|
| | | public void addSalesCount(Long id,int count);
|
| | |
|
| | | /**
|
| | | * 后台维护
|
| | | * @param file
|
| | | * @param file2
|
| | | * @param record
|
| | | * @throws BanLiShopGoodsSetException
|
| | | * @throws Exception
|
| | | */
|
| | | public void saveObject(MultipartFile file, MultipartFile file2, BanLiShopGoods record)
|
| | | throws BanLiShopGoodsException, Exception;
|
| | | |
| | |
|
| | | }
|
| | |
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopGoodsSetsPay;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetException;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopGoodsSetPayException;
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | public long countQuery(String key, Integer payType, Long setId);
|
| | |
|
| | | /**
|
| | | * 后台编辑
|
| | | * @param record
|
| | | * @throws BanLiShopGoodsSetException
|
| | | */
|
| | | public void saveObject(BanLiShopGoodsSetsPay record) throws BanLiShopGoodsSetPayException;
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void addSalesCount(Long id,int count);
|
| | |
|
| | | /**
|
| | | * 后台编辑
|
| | | * @param record
|
| | | * @throws BanLiShopGoodsSetException
|
| | | */
|
| | | public void saveObject(BanLiShopGoodsSets record) throws BanLiShopGoodsSetException;
|
| | |
|
| | | }
|
| | |
| | | userMsgVO.setTime(msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime());
|
| | | userMsgVO.setContentItems(items);
|
| | | return userMsgVO;
|
| | | } else if (msg.getType() == MsgTypeOtherTypeEnum.taoLiJinExchange) {
|
| | | if (StringUtil.isNullOrEmpty(msg.getContent()))
|
| | | return null;
|
| | |
|
| | | MsgOtherRewardIntegralDTO dto = new Gson().fromJson(msg.getContent(), MsgOtherRewardIntegralDTO.class);
|
| | | if (dto == null)
|
| | | return null;
|
| | |
|
| | | icon = "http://img.flqapp.com/resource/msg/icon_msg_other_system_give.png";
|
| | |
|
| | | List<ClientTextStyleVO> contentList = new ArrayList<>();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(dto.getExplain())) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getExplain() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("原因", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | if (dto.getTotal() != null) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getTotal(), COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("可则算额", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(dto.getNum())) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getNum() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("折算金币", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(dto.getSource())) {
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getSource(), COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList));
|
| | | }
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
|
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | |
|
| | | UserMsgVO userMsgVO = new UserMsgVO();
|
| | | userMsgVO.setIcon(icon);
|
| | | userMsgVO.setTitle(dto.getTitle());
|
| | | userMsgVO.setTime(msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime());
|
| | | userMsgVO.setContentItems(items);
|
| | | return userMsgVO;
|
| | | }
|
| | |
|
| | | return new UserMsgVO(icon, msg.getType().getDesc(),
|