|
@@ -1,10 +1,12 @@
|
|
|
package com.uas.platform.b2c.fa.payment.service.impl;
|
|
package com.uas.platform.b2c.fa.payment.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.fa.payment.dao.InstallmentStoreDao;
|
|
import com.uas.platform.b2c.fa.payment.dao.InstallmentStoreDao;
|
|
|
import com.uas.platform.b2c.fa.payment.model.InstallmentStore;
|
|
import com.uas.platform.b2c.fa.payment.model.InstallmentStore;
|
|
|
import com.uas.platform.b2c.fa.payment.service.InstallmentStoreService;
|
|
import com.uas.platform.b2c.fa.payment.service.InstallmentStoreService;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
|
|
+import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -15,37 +17,79 @@ import org.springframework.stereotype.Service;
|
|
|
* @version 2017/9/7 11:23 wangyc
|
|
* @version 2017/9/7 11:23 wangyc
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class InstallmentStoreServiceImpl implements InstallmentStoreService {
|
|
|
|
|
|
|
+public class InstallmentStoreServiceImpl implements InstallmentStoreService{
|
|
|
|
|
|
|
|
private final InstallmentStoreDao installmentStoreDao;
|
|
private final InstallmentStoreDao installmentStoreDao;
|
|
|
|
|
|
|
|
|
|
+ private final StoreInDao storeInDao;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- public InstallmentStoreServiceImpl(InstallmentStoreDao installmentStoreDao) {
|
|
|
|
|
|
|
+ public InstallmentStoreServiceImpl(InstallmentStoreDao installmentStoreDao, StoreInDao storeInDao) {
|
|
|
this.installmentStoreDao = installmentStoreDao;
|
|
this.installmentStoreDao = installmentStoreDao;
|
|
|
|
|
+ this.storeInDao = storeInDao;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void saveStore(String storeUuid, Long storeId, Long enuu, Short enable) {
|
|
|
|
|
- installmentStoreDao.saveStore(storeUuid, storeId, enuu, enable);
|
|
|
|
|
|
|
+ public InstallmentStore saveStore(String storeUuid) {
|
|
|
|
|
+ StoreIn storeIn = storeInDao.findByUuid(storeUuid);
|
|
|
|
|
+ if (storeIn == null)
|
|
|
|
|
+ throw new IllegalOperatorException("此店铺不存在,请重新确认店铺信息");
|
|
|
|
|
+
|
|
|
|
|
+ InstallmentStore installmentStore = installmentStoreDao.findByStoreUuid(storeUuid);
|
|
|
|
|
+ if (installmentStore != null)
|
|
|
|
|
+ throw new IllegalOperatorException("店铺: " + storeIn.getStoreName() + " 已存在权限列表中,如需维护请找到该店铺进行维护");
|
|
|
|
|
+
|
|
|
|
|
+ installmentStore.setEnable((short) 1);
|
|
|
|
|
+ installmentStore.setEnuu(storeIn.getEnUU());
|
|
|
|
|
+ installmentStore.setStoreId(storeIn.getId());
|
|
|
|
|
+ installmentStore.setStoreUuid(storeUuid);
|
|
|
|
|
+
|
|
|
|
|
+ return installmentStoreDao.save(installmentStore);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void deleteStore(Long id) {
|
|
|
|
|
- installmentStoreDao.deleteStore(id);
|
|
|
|
|
|
|
+ public void deleteStore(String storeUuid) {
|
|
|
|
|
+ InstallmentStore installmentStore = installmentStoreDao.findByStoreUuid(storeUuid);
|
|
|
|
|
+ if (installmentStore == null)
|
|
|
|
|
+ throw new IllegalOperatorException("此店铺并不存在权限列表中,无需删除");
|
|
|
|
|
+ installmentStoreDao.delete(installmentStore.getId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void capsOFF(String storeUuid) {
|
|
|
|
|
- installmentStoreDao.updateStore(storeUuid,(short)1);
|
|
|
|
|
|
|
+ public InstallmentStore capsOFF(String storeUuid) {
|
|
|
|
|
+ return toggleStore(storeUuid, (short) 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void capsON(String storeUuid) {
|
|
|
|
|
- installmentStoreDao.updateStore(storeUuid,(short)0);
|
|
|
|
|
|
|
+ public InstallmentStore capsON(String storeUuid) {
|
|
|
|
|
+ return toggleStore(storeUuid, (short) 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启用/禁用店铺
|
|
|
|
|
+ * @param enable
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public InstallmentStore toggleStore(String storeUuid, short enable) {
|
|
|
|
|
+ InstallmentStore installmentStore = installmentStoreDao.findByStoreUuid(storeUuid);
|
|
|
|
|
+ if (installmentStore == null)
|
|
|
|
|
+ throw new IllegalOperatorException("此店铺并不存在权限列表中,无需删除");
|
|
|
|
|
+
|
|
|
|
|
+ installmentStore.setEnable(enable);
|
|
|
|
|
+
|
|
|
|
|
+ return installmentStoreDao.save(installmentStore);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public InstallmentStore getInstallmentByEnuuAndEnable(Long enuu, Short enable) {
|
|
|
|
|
- return installmentStoreDao.findByEnuuAndEnable(enuu, enable);
|
|
|
|
|
|
|
+ public String capsOFFVerify() {
|
|
|
|
|
+ if (SystemSession.getUser().getEnterprise() == null)
|
|
|
|
|
+ throw new IllegalOperatorException("当前用户为个人用户,请选择企业进行分期操作");
|
|
|
|
|
+
|
|
|
|
|
+ InstallmentStore installmentStore = installmentStoreDao.findByEnuuAndEnable(SystemSession.getUser().getEnterprise().getUu(), (short) 1);
|
|
|
|
|
+ if (installmentStore == null) {
|
|
|
|
|
+ return "fail";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return "success";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|