|
@@ -776,6 +776,51 @@ function checkCollectionState($id=''){
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 判断藏品状态
|
|
|
+ */
|
|
|
+function checkSynCollectionState($id=''){
|
|
|
+ if ($id){
|
|
|
+ $info = Db::name('store_collection')->where('id',$id)->find();
|
|
|
+ $now_inventory = getCollectionInventory($id);
|
|
|
+ if ($info['sy_state']==1){
|
|
|
+ if ($now_inventory<=0){
|
|
|
+ Db::name('store_collection')->where('id',$info['id'])->update(['sy_state'=>4]);
|
|
|
+ }elseif(strtotime($info['end_time'])<time()){
|
|
|
+ Db::name('store_collection')->where('id',$info['id'])->update(['sy_state'=>3]);
|
|
|
+ }
|
|
|
+ }elseif ($info['sy_state']==2){
|
|
|
+ if (strtotime($info['sell_time'])<=time()){
|
|
|
+ Db::name('store_collection')->where('id',$info['id'])->update(['sy_state'=>1]);
|
|
|
+ }elseif ($now_inventory<=0){
|
|
|
+ Db::name('store_collection')->where('id',$info['id'])->update(['sy_state'=>4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $list = Db::name('store_collection')
|
|
|
+ ->where('type',2)
|
|
|
+ ->whereIn('sy_state','1,2')
|
|
|
+ ->where('is_deleted',0)
|
|
|
+ ->select();
|
|
|
+ foreach ($list as &$v){
|
|
|
+ $now_inventory = getCollectionInventory($v['id']);
|
|
|
+ if ($v['sy_state']==1){
|
|
|
+ if ($now_inventory<=0){
|
|
|
+ Db::name('store_collection')->where('id',$v['id'])->update(['sy_state'=>4]);
|
|
|
+ }elseif(strtotime($v['end_time'])<time()){
|
|
|
+ Db::name('store_collection')->where('id',$v['id'])->update(['sy_state'=>3]);
|
|
|
+ }
|
|
|
+ }elseif ($v['sy_state']==2){
|
|
|
+ if (strtotime($v['sell_time'])<=time()){
|
|
|
+ Db::name('store_collection')->where('id',$v['id'])->update(['sy_state'=>1]);
|
|
|
+ }elseif ($now_inventory<=0){
|
|
|
+ Db::name('store_collection')->where('id',$v['id'])->update(['sy_state'=>4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* redis加锁
|
|
|
*/
|
|
|
function redisSetNx($id){
|