Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2024-11-25 11:49:59 +08:00
4 changed files with 64 additions and 47 deletions

View File

@@ -10,18 +10,22 @@ import java.util.List;
import java.util.Map;
/**
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
* 挂账账单
*
* @author Tankaikai tankaikai@aliyun.com
* @since 2.0 2024-11-20
*/
@Mapper
public interface TbCreditBuyerOrderMapper extends BaseMapper<TbCreditBuyerOrder> {
List<CreditBuyerOrderDTO> getList(Map<String, Object> params);
long getCount(Map<String, Object> params);
BigDecimal getSumPayAmount(Map<String, Object> params);
BigDecimal getSumPaidAmount(Map<String, Object> params);
BigDecimal getSumUnpaidAmount(Map<String, Object> params);
CreditBuyerOrderDTO getOne(Map<String, Object> params);

View File

@@ -81,6 +81,11 @@ public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrde
Map<String, Object> data = new HashMap<>(4);
// 总交易笔数
data.put("count", count);
// 总交易金额
BigDecimal payAmount = baseMapper.getSumPayAmount(params);
data.put("payAmountTotal", payAmount);
// 未支付
params.put("status", "unpaid");
long unpaidCount = baseMapper.getCount(params);

View File

@@ -49,11 +49,11 @@ import java.time.Instant;
import java.util.*;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author lyf
* @date 2023-11-07
**/
* @author lyf
* @website https://eladmin.vip
* @description 服务实现
* @date 2023-11-07
**/
@Service
@RequiredArgsConstructor
public class TbShopInfoServiceImpl implements TbShopInfoService {
@@ -86,9 +86,11 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
public JSONObject binding(BindingDto bindingDto) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(bindingDto.getShopId()).orElseGet(null);
TbMerchantAccount account = merchantAccountRepository.findByAccount(tbShopInfo.getAccount());
boolean isNew = true;
if (org.apache.commons.lang3.StringUtils.isBlank(bindingDto.getAccount())) {
if (tbShopInfo != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(account.getBindAccount())) {
isNew = false;
bindingDto.setAccount(account.getBindAccount());
} else {
return null;
@@ -98,7 +100,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
Map<String, Object> param = new HashMap<>();
param.put("account", bindingDto.getAccount());
JSONObject data = bindService.binding(param);
if (org.apache.commons.lang3.StringUtils.isNotBlank(bindingDto.getAccount())) {
if (isNew) {
account.setBindAccount(bindingDto.getAccount());
account.setArticle(bindingDto.getArticle());
account.setTaxAmount(bindingDto.getTaxAmount());
@@ -113,15 +115,15 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
}
@Override
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){
public Map<String, Object> queryAll(TbShopInfoQueryCriteria criteria) {
Sort sort = Sort.by(Sort.Direction.DESC, "id");
Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables);
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageables);
return PageUtil.toPage(page);
}
@Override
public List<TbShopInfo> queryChildShop(TbShopInfoQueryCriteria criteria){
public List<TbShopInfo> queryChildShop(TbShopInfoQueryCriteria criteria) {
List<TbShopInfo> list = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> {
Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId());
Predicate query2 = criteriaBuilder.and(
@@ -148,14 +150,14 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
@Transactional
public TbShopInfoDto findById(Integer id) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(id).orElseGet(TbShopInfo::new);
if(StringUtils.isBlank(tbShopInfo.getSmallQrcode())){
if (StringUtils.isBlank(tbShopInfo.getSmallQrcode())) {
String smallQrcode = wxService.getSmallQrcode(id.toString());
tbShopInfo.setSmallQrcode(smallQrcode);
tbShopInfoRepository.save(tbShopInfo);
}
String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id);
ValidationUtil.isNull(tbShopInfo.getId(),"TbShopInfo","id",id);
tbShopInfo.setPaymentQrcode(baseUrl + "?shopId=" + id);
ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", id);
return tbShopInfoMapper.toDto(tbShopInfo);
}
@@ -168,46 +170,46 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
@Override
@Transactional(rollbackFor = Exception.class)
public TbShopInfoDto create(TbShopInfoDto resources) {
if(StringUtils.isBlank(resources.getShopName())){
if (StringUtils.isBlank(resources.getShopName())) {
throw new BadRequestException("店铺名称不可为空");
}
resources.setShopName(resources.getShopName().trim());
if ("release".equals(resources.getProfiles())){
if (resources.getRegisterCode() == null){
if ("release".equals(resources.getProfiles())) {
if (resources.getRegisterCode() == null) {
throw new BadRequestException("未绑定激活码");
}
}
TbShopInfo byAccount = tbShopInfoRepository.findByAccount(resources.getAccount());
User byUsername = userRepository.findByUsername(resources.getAccount());
if (byAccount != null || byUsername != null){
if (byAccount != null || byUsername != null) {
throw new BadRequestException("登录名已注册");
}
TbShopInfo tbShopInfo = new TbShopInfo();
BeanUtil.copyProperties(resources,tbShopInfo, CopyOptions.create().setIgnoreNullValue(true));
BeanUtil.copyProperties(resources, tbShopInfo, CopyOptions.create().setIgnoreNullValue(true));
tbShopInfo.setCreatedAt(Instant.now().toEpochMilli());
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
tbShopInfo.setIsOpenYhq(resources.getIsOpenYhq());
//激活码
TbMerchantRegister tbMerchantRegister = new TbMerchantRegister();
if (resources.getRegisterCode() != null){
if (resources.getRegisterCode() != null) {
tbMerchantRegister = merchantRegisterRepository.findByRegisterCode(resources.getRegisterCode());
if(tbMerchantRegister == null){
if (tbMerchantRegister == null) {
throw new BadRequestException("激活码有误");
}
if (tbMerchantRegister.getStatus() == 1){
if (tbMerchantRegister.getStatus() == 1) {
throw new BadRequestException("激活码已激活,不能重复绑定");
}
tbShopInfo.setExpireAt(DateUtil.addMonthsAndGetTimestamp(tbMerchantRegister.getPeriodYear()));
//向redis中存入key
redisUtils.set(CacheKey.ACT_CODE+resources.getAccount(),"1",tbShopInfo.getExpireAt()-Instant.now().toEpochMilli());
redisUtils.set(CacheKey.ACT_CODE + resources.getAccount(), "1", tbShopInfo.getExpireAt() - Instant.now().toEpochMilli());
}
if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){
if(resources.getMainId() == null){
if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) {
if (resources.getMainId() == null) {
throw new BadRequestException("连锁店或者扩展店 主店铺不能为空");
}
}else {
} else {
tbShopInfo.setMainId(null);
tbShopInfo.setTubeType(1);
}
@@ -275,7 +277,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
shopStaffRepository.save(tbPlussShopStaff);
//增加默认支付方式
Integer integer = tbShopPayTypeRepository.creatPayType(save.getId().toString());
if (integer<4){
if (integer < 4) {
throw new BadRequestException("请重试");
}
TbProductGroup tbProductGroup = new TbProductGroup();
@@ -290,35 +292,35 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
@Override
@Transactional
public void upShopPass(String username,String password){
public void upShopPass(String username, String password) {
User user = userRepository.findByUsername(username);
if (user == null) {
throw new EntityNotFoundException(User.class, "username", username);
}
String encPass = MD5Utils.encrypt(password);
shopStaffRepository.updatePass(username,encPass,System.currentTimeMillis());
merchantAccountRepository.updatePass(username,encPass,System.currentTimeMillis());
shopStaffRepository.updatePass(username, encPass, System.currentTimeMillis());
merchantAccountRepository.updatePass(username, encPass, System.currentTimeMillis());
// passwordEncoder.encode(passwordEncoder.encode(password))
userService.updatePass(username,passwordEncoder.encode(password));
userService.updatePass(username, passwordEncoder.encode(password));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbShopInfo resources) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){
if(resources.getMainId() == null){
if (org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())) {
if (resources.getMainId() == null) {
throw new BadRequestException("连锁店或者扩展店 主店铺不能为空");
}
}else {
} else {
tbShopInfo.setMainId(null);
tbShopInfo.setTubeType(1);
}
if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) {
shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString());
userRepository.updateNickName(resources.getAccount(),resources.getShopName());
shopStaffRepository.updateNameById(resources.getShopName(), resources.getId().toString());
userRepository.updateNickName(resources.getAccount(), resources.getShopName());
}
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId());
tbShopInfo.copy(resources);
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
tbShopInfoRepository.save(tbShopInfo);
@@ -327,7 +329,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
@Override
public void updateShopId(TbShopInfo resources) {
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
ValidationUtil.isNull(tbShopInfo.getId(), "TbShopInfo", "id", resources.getId());
tbShopInfo.copy(resources);
}
@@ -348,7 +350,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
public void download(List<TbShopInfoDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbShopInfoDto tbShopInfo : all) {
Map<String,Object> map = new LinkedHashMap<>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("店铺帐号", tbShopInfo.getAccount());
map.put("店铺代号策略方式为city +店铺号8位", tbShopInfo.getShopCode());
map.put("店铺口号", tbShopInfo.getSubTitle());
@@ -369,7 +371,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
map.put("经纬度", tbShopInfo.getLat());
map.put("经纬度", tbShopInfo.getLng());
map.put("未用", tbShopInfo.getMchId());
map.put(" registerType", tbShopInfo.getRegisterType());
map.put(" registerType", tbShopInfo.getRegisterType());
map.put("是否独立的微信小程序", tbShopInfo.getIsWxMaIndependent());
map.put("详细地址", tbShopInfo.getAddress());
map.put("类似于这种规则51.51.570", tbShopInfo.getCity());
@@ -378,7 +380,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
map.put("行业名称", tbShopInfo.getIndustryName());
map.put("营业时间", tbShopInfo.getBusinessTime());
map.put("配送时间", tbShopInfo.getPostTime());
map.put(" postAmountLine", tbShopInfo.getPostAmountLine());
map.put(" postAmountLine", tbShopInfo.getPostAmountLine());
map.put("0停业1正常营业,网上售卖", tbShopInfo.getOnSale());
map.put("0今日1次日", tbShopInfo.getSettleType());
map.put("时间", tbShopInfo.getSettleTime());
@@ -389,9 +391,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
map.put("订单等待时间", tbShopInfo.getOrderWaitPayMinute());
map.put("支持登陆设备个数", tbShopInfo.getSupportDeviceNumber());
map.put("分销层级1-下级分销 2-两下级分销)", tbShopInfo.getDistributeLevel());
map.put(" createdAt", tbShopInfo.getCreatedAt());
map.put(" updatedAt", tbShopInfo.getUpdatedAt());
map.put(" proxyId", tbShopInfo.getProxyId());
map.put(" createdAt", tbShopInfo.getCreatedAt());
map.put(" updatedAt", tbShopInfo.getUpdatedAt());
map.put(" proxyId", tbShopInfo.getProxyId());
list.add(map);
}
FileUtil.downloadExcel(list, response);

View File

@@ -51,6 +51,12 @@
order by t1.order_id desc
</select>
<select id="getSumPayAmount" resultType="decimal">
select ifnull(sum(t1.pay_amount),0) from view_credit_buyer_order t1
<include refid="commonWhere" />
order by t1.order_id desc
</select>
<select id="getSumPaidAmount" resultType="decimal">
select ifnull(sum(t1.paid_amount),0) from view_credit_buyer_order t1
<include refid="commonWhere" />