|
|
|
@@ -5,11 +5,20 @@ import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.domain.po.WxFinancePrintData; |
|
|
|
import com.iformall.domain.po.WxFinancePrintTemplate; |
|
|
|
import com.iformall.enums.EnumYesOrNo; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxFinancePrintDataMapper; |
|
|
|
import com.iformall.mapper.WxFinancePrintTemplateMapper; |
|
|
|
import com.iformall.service.WxFinancePrintService; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -40,7 +49,42 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveOrUpdate(WxFinancePrintTemplate record) { |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
if (record.getId() == null) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setCreateTime(date); |
|
|
|
record.setUpdateTime(date); |
|
|
|
if (null != record.getContentJson()) { |
|
|
|
JSONObject o = record.getContentJson(); |
|
|
|
o.put("type", record.getType()); |
|
|
|
o.put("id", String.valueOf(record.getId())); |
|
|
|
o.put("defaultValue", 0); |
|
|
|
record.setContent(JSON.toJSONString(o)); |
|
|
|
} |
|
|
|
try { |
|
|
|
wxFinancePrintTemplateMapper.insert(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("保存模板失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (null != record.getContentJson()) { |
|
|
|
JSONObject o = record.getContentJson(); |
|
|
|
o.put("type", record.getType()); |
|
|
|
o.put("id", String.valueOf(record.getId())); |
|
|
|
o.put("defaultValue", 0); |
|
|
|
record.setContent(JSON.toJSONString(o)); |
|
|
|
} |
|
|
|
record.setUpdateTime(date); |
|
|
|
wxFinancePrintTemplateMapper.updateById(record); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void setTemplatesDel(WxFinancePrintTemplate record) { |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
wxFinancePrintTemplateMapper.updateById(record); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|